Skip to content

Commit

Permalink
leds: led-core: Fix refcount leak in of_led_get()
Browse files Browse the repository at this point in the history
class_find_device_by_of_node() calls class_find_device(), it will take
the reference, use the put_device() to drop the reference when not need
anymore.

Fixes: 699a8c7 ("leds: Add of_led_get() and led_put()")
Signed-off-by: Miaoqian Lin <[email protected]>
Signed-off-by: Lee Jones <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
Yuuoniy authored and lag-linaro committed Jan 30, 2023
1 parent d8960df commit da1afe8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/leds/led-class.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ struct led_classdev *of_led_get(struct device_node *np, int index)

led_dev = class_find_device_by_of_node(leds_class, led_node);
of_node_put(led_node);
put_device(led_dev);

return led_module_get(led_dev);
}
Expand Down

0 comments on commit da1afe8

Please sign in to comment.