From: Guangshuo Li <lgs201920130244@gmail.com>
To: Lee Jones <lee@kernel.org>, Pavel Machek <pavel@kernel.org>,
Jonathan Cameron <jic23@kernel.org>,
Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
Armin Wolf <W_Armin@gmx.de>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Guangshuo Li <lgs201920130244@gmail.com>,
Abdel Alkuor <alkuor@gmail.com>,
linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH] leds: ncp5623: release multi-led fwnode on remove
Date: Mon, 14 Sep 2026 22:07:42 +0800 [thread overview]
Message-ID: <20260914140742.1743052-1-lgs201920130244@gmail.com> (raw)
ncp5623_probe() obtains a reference to the multi-led firmware node with
device_get_named_child_node(). This reference must remain valid after
probe because led_classdev_register_ext() associates the node with the
LED class device using device_set_node(), which does not acquire an
additional reference.
The probe error paths correctly release mc_node, while the successful
path intentionally keeps the reference alive for the lifetime of the
registered LED device. However, ncp5623_remove() unregisters the LED
class device without subsequently dropping that reference, leaking the
firmware node on driver unbind.
Save the firmware node pointer before unregistering the LED device and
drop its reference afterwards, when the LED device can no longer use
it.
This issue was found by manual code inspection.
Fixes: 7b7e50f8f5e0 ("leds: Add NCP5623 multi-led driver")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
drivers/leds/rgb/leds-ncp5623.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/leds/rgb/leds-ncp5623.c b/drivers/leds/rgb/leds-ncp5623.c
index f2528f06507d..f96f15b7e9a1 100644
--- a/drivers/leds/rgb/leds-ncp5623.c
+++ b/drivers/leds/rgb/leds-ncp5623.c
@@ -227,6 +227,8 @@ static int ncp5623_probe(struct i2c_client *client)
static void ncp5623_remove(struct i2c_client *client)
{
struct ncp5623 *ncp = i2c_get_clientdata(client);
+ struct fwnode_handle *mc_node =
+ dev_fwnode(ncp->mc_dev.led_cdev.dev);
mutex_lock(&ncp->lock);
ncp->delay = 0;
@@ -234,6 +236,7 @@ static void ncp5623_remove(struct i2c_client *client)
ncp5623_write(client, NCP5623_DIMMING_TIME_REG, 0);
led_classdev_multicolor_unregister(&ncp->mc_dev);
+ fwnode_handle_put(mc_node);
mutex_destroy(&ncp->lock);
}
--
2.43.0
next reply other threads:[~2026-09-14 14:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 14:07 Guangshuo Li [this message]
2026-09-14 14:22 ` Laurent Pinchart
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=20260914140742.1743052-1-lgs201920130244@gmail.com \
--to=lgs201920130244@gmail.com \
--cc=W_Armin@gmx.de \
--cc=alkuor@gmail.com \
--cc=jic23@kernel.org \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®