From: Miaoqian Lin <linmq006@gmail.com>
To: Pavel Machek <pavel@ucw.cz>, Lee Jones <lee@kernel.org>,
Jean-Jacques Hiblot <jjhiblot@ti.com>,
Tomi Valkeinen <tomi.valkeinen@ti.com>,
linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: linmq006@gmail.com
Subject: [PATCH] leds: led-core: Fix refcount leak in of_led_get
Date: Tue, 20 Dec 2022 16:18:07 +0400 [thread overview]
Message-ID: <20221220121807.1543790-1-linmq006@gmail.com> (raw)
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
next reply other threads:[~2022-12-20 12:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-20 12:18 Miaoqian Lin [this message]
2023-01-04 18:58 ` [PATCH] leds: led-core: Fix refcount leak in of_led_get Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221220121807.1543790-1-linmq006@gmail.com \
--to=linmq006@gmail.com \
--cc=jjhiblot@ti.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=tomi.valkeinen@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox