[PATCH] auxdisplay: charlcd: cancel backlight work on registration failure

Hongyan Xu posted 1 patch 5 days, 12 hours ago
drivers/auxdisplay/charlcd.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
[PATCH] auxdisplay: charlcd: cancel backlight work on registration failure
Posted by Hongyan Xu 5 days, 12 hours ago
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
Re: [PATCH] auxdisplay: charlcd: cancel backlight work on registration failure
Posted by Miguel Ojeda 5 days, 11 hours ago
On Sun, Jul 19, 2026 at 4:43 PM Hongyan Xu <getshell@seu.edu.cn> wrote:
>
> 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>

I think you may have used an out-of-date `MAINTAINERS` file...

Cc'ing auxdisplay as well as Lars and Willy who were involved in the
past with `charlcd`.

I hope that helps!

Cheers,
Miguel