mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] auxdisplay: charlcd: cancel backlight work on registration failure
@ 2026-07-19 14:43 Hongyan Xu
  2026-07-19 15:53 ` Miguel Ojeda
  0 siblings, 1 reply; 5+ messages in thread
From: Hongyan Xu @ 2026-07-19 14:43 UTC (permalink / raw)
  To: ojeda; +Cc: linux-kernel, jianhao.xu, getshell

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


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

end of thread, other threads:[~2026-08-12  9:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-19 14:43 [PATCH] auxdisplay: charlcd: cancel backlight work on registration failure Hongyan Xu
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

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®