From: Hongyan Xu <getshell@seu.edu.cn>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
jianhao.xu@seu.edu.cn, getshell@seu.edu.cn
Subject: [PATCH] Input: lm8323 - cancel PWM work before releasing device data
Date: Tue, 28 Jul 2026 14:55:18 +0800 [thread overview]
Message-ID: <20260728065518.489-1-getshell@seu.edu.cn> (raw)
LED class device teardown sets the LED brightness to off. The LM8323
brightness callback responds by scheduling its private PWM work, while
LED core only flushes the class device's own work item.
Register a devm action before each LED class device. Devres teardown then
unregisters the LED first, cancels any resulting PWM work, and only then
releases the containing LM8323 data.
This issue was found by a static analysis tool.
Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
---
drivers/input/keyboard/lm8323.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/input/keyboard/lm8323.c b/drivers/input/keyboard/lm8323.c
index 7bee93e..1d799ce 100644
--- a/drivers/input/keyboard/lm8323.c
+++ b/drivers/input/keyboard/lm8323.c
@@ -552,6 +552,13 @@ static struct attribute *lm8323_pwm_attrs[] = {
};
ATTRIBUTE_GROUPS(lm8323_pwm);
+static void lm8323_cancel_pwm_work(void *data)
+{
+ struct lm8323_pwm *pwm = data;
+
+ cancel_work_sync(&pwm->work);
+}
+
static int init_pwm(struct lm8323_chip *lm, int id, struct device *dev,
const char *name)
{
@@ -572,6 +579,10 @@ static int init_pwm(struct lm8323_chip *lm, int id, struct device *dev,
mutex_init(&pwm->lock);
pwm->chip = lm;
+ err = devm_add_action_or_reset(dev, lm8323_cancel_pwm_work, pwm);
+ if (err)
+ return err;
+
if (name) {
pwm->cdev.name = name;
pwm->cdev.brightness_set = lm8323_pwm_set_brightness;
--
2.50.1.windows.1
reply other threads:[~2026-07-28 6:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260728065518.489-1-getshell@seu.edu.cn \
--to=getshell@seu.edu.cn \
--cc=dmitry.torokhov@gmail.com \
--cc=jianhao.xu@seu.edu.cn \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@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®