public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] leds: led-core: Fix refcount leak in of_led_get
@ 2022-12-20 12:18 Miaoqian Lin
  2023-01-04 18:58 ` Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Miaoqian Lin @ 2022-12-20 12:18 UTC (permalink / raw)
  To: Pavel Machek, Lee Jones, Jean-Jacques Hiblot, Tomi Valkeinen,
	linux-leds, linux-kernel
  Cc: linmq006

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>
---
 drivers/leds/led-class.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 6a8ea94834fa..705b7a89f3d8 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -240,6 +240,7 @@ struct led_classdev *of_led_get(struct device_node *np, int index)
 		return ERR_PTR(-EPROBE_DEFER);
 
 	led_cdev = dev_get_drvdata(led_dev);
+	put_device(led_dev);
 
 	if (!try_module_get(led_cdev->dev->parent->driver->owner))
 		return ERR_PTR(-ENODEV);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-04 18:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-20 12:18 [PATCH] leds: led-core: Fix refcount leak in of_led_get Miaoqian Lin
2023-01-04 18:58 ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox