Skip to content

Commit f64dd42

Browse files
javiercarrascocruzlag-linaro
authored andcommitted
leds: flash: leds-qcom-flash: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error paths. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). Signed-off-by: Javier Carrasco <[email protected]> Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-3-95c0614b38c8@gmail.com Signed-off-by: Lee Jones <[email protected]>
1 parent 19d1cc7 commit f64dd42

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/leds/flash/leds-qcom-flash.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,6 @@ static int qcom_flash_led_probe(struct platform_device *pdev)
812812
{
813813
struct qcom_flash_data *flash_data;
814814
struct qcom_flash_led *led;
815-
struct fwnode_handle *child;
816815
struct device *dev = &pdev->dev;
817816
struct regmap *regmap;
818817
struct reg_field *regs;
@@ -896,7 +895,7 @@ static int qcom_flash_led_probe(struct platform_device *pdev)
896895
if (!flash_data->v4l2_flash)
897896
return -ENOMEM;
898897

899-
device_for_each_child_node(dev, child) {
898+
device_for_each_child_node_scoped(dev, child) {
900899
led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
901900
if (!led) {
902901
rc = -ENOMEM;
@@ -914,7 +913,6 @@ static int qcom_flash_led_probe(struct platform_device *pdev)
914913
return 0;
915914

916915
release:
917-
fwnode_handle_put(child);
918916
while (flash_data->v4l2_flash[flash_data->leds_count] && flash_data->leds_count)
919917
v4l2_flash_release(flash_data->v4l2_flash[flash_data->leds_count--]);
920918
return rc;

0 commit comments

Comments
 (0)