@@ -91,12 +91,12 @@ static int spi_byte_probe(struct spi_device *spi)
dev_err(dev, "Device must have exactly one LED sub-node.");
return -EINVAL;
}
- child = of_get_next_available_child(dev_of_node(dev), NULL);
led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
if (!led)
return -ENOMEM;
+ child = of_get_next_available_child(dev_of_node(dev), NULL);
of_property_read_string(child, "label", &name);
strlcpy(led->name, name, sizeof(led->name));
led->spi = spi;
@@ -113,10 +113,12 @@ static int spi_byte_probe(struct spi_device *spi)
led->ldev.brightness = led->ldev.max_brightness;
} else if (strcmp(state, "off")) {
/* all other cases except "off" */
+ of_node_put(child);
dev_err(dev, "default-state can only be 'on' or 'off'");
return -EINVAL;
}
}
+ of_node_put(child);
spi_byte_brightness_set_blocking(&led->ldev,
led->ldev.brightness);