mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hongyan Xu <getshell@seu.edu.cn>
To: ojeda@kernel.org
Cc: linux-kernel@vger.kernel.org, jianhao.xu@seu.edu.cn, getshell@seu.edu.cn
Subject: [PATCH] auxdisplay: charlcd: cancel backlight work on registration failure
Date: Sun, 19 Jul 2026 22:43:05 +0800	[thread overview]
Message-ID: <20260719144305.1108-1-getshell@seu.edu.cn> (raw)

With CONFIG_CHARLCD_BL_FLASH, charlcd_init() schedules bl_work before
charlcd_register() calls misc_register(). If registration fails, the
caller frees the charlcd object while delayed work still contains its
address.

Cancel the delayed work and turn the backlight off before returning the
registration error.

Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
---
 drivers/auxdisplay/charlcd.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c
index 6d309e4..92530e0 100644
--- a/drivers/auxdisplay/charlcd.c
+++ b/drivers/auxdisplay/charlcd.c
@@ -645,6 +645,7 @@ static struct notifier_block panel_notifier = {
 
 int charlcd_register(struct charlcd *lcd)
 {
+	struct charlcd_priv *priv = charlcd_to_priv(lcd);
 	int ret;
 
 	ret = charlcd_init(lcd);
@@ -652,8 +653,13 @@ int charlcd_register(struct charlcd *lcd)
 		return ret;
 
 	ret = misc_register(&charlcd_dev);
-	if (ret)
+	if (ret) {
+		if (lcd->ops->backlight) {
+			cancel_delayed_work_sync(&priv->bl_work);
+			lcd->ops->backlight(lcd, CHARLCD_OFF);
+		}
 		return ret;
+	}
 
 	the_charlcd = lcd;
 	register_reboot_notifier(&panel_notifier);
-- 
2.50.1.windows.1


             reply	other threads:[~2026-07-19 14:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-19 14:43 Hongyan Xu [this message]
2026-07-19 15:53 ` Miguel Ojeda
2026-08-12  8:37   ` Andy Shevchenko
2026-08-12  8:50     ` Geert Uytterhoeven
2026-08-12  9:31       ` Andy Shevchenko

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=20260719144305.1108-1-getshell@seu.edu.cn \
    --to=getshell@seu.edu.cn \
    --cc=jianhao.xu@seu.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@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®