summary refs log tree commit diff
path: root/drivers/leds
diff options
context:
space:
mode:
authorMiaoqian Lin <linmq006@gmail.com>2022-12-20 16:18:07 +0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-03-10 09:33:26 +0100
commitd880981b82223f9bf128dfdd2424abb0c658f345 (patch)
tree07a512de089589684f01f7364fafe87ff25c53a4 /drivers/leds
parent062547cbcd05c241ed95351d701dc80b2dc93832 (diff)
downloadlinux-d880981b82223f9bf128dfdd2424abb0c658f345.tar.gz
leds: led-core: Fix refcount leak in of_led_get()
[ Upstream commit da1afe8e6099980fe1e2fd7436dca284af9d3f29 ]

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: 699a8c7c4bd3 ("leds: Add of_led_get() and led_put()")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20221220121807.1543790-1-linmq006@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/led-class.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 7391d2cf1370..aa39b2a48fdf 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -235,6 +235,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);
 
 	if (!led_dev)
 		return ERR_PTR(-EPROBE_DEFER);