mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] auxdisplay: charlcd: cancel backlight work on registration failure
@ 2026-08-15 10:59 Hongyan Xu
  2026-08-15 11:54 ` Miguel Ojeda
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Hongyan Xu @ 2026-08-15 10:59 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andy Shevchenko, Geert Uytterhoeven, Miguel Ojeda, Miguel Ojeda,
	linux-kernel, stable, Jianhao Xu, Lars Poeschel, Willy Tarreau,
	Hongyan Xu

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.

Add charlcd_deinit() to cancel the delayed work and turn the backlight
off. Use it for both registration rollback and normal unregistration.

Fixes: 39f8ea46724e ("auxdisplay: charlcd: Extract character LCD core from misc/panel")
Cc: stable@vger.kernel.org
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
---
Changes in v3:
- Add Cc: stable@vger.kernel.org (Miguel).

Changes in v2:
- Factor the backlight cleanup into charlcd_deinit() and reuse it from
  charlcd_unregister() (Andy, Geert).
- Add the Fixes tag (Andy).

 drivers/auxdisplay/charlcd.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c
index 09020bb8ad15..ae2692ec3963 100644
--- a/drivers/auxdisplay/charlcd.c
+++ b/drivers/auxdisplay/charlcd.c
@@ -595,6 +595,16 @@ static int charlcd_init(struct charlcd *lcd)
 	return 0;
 }
 
+static void charlcd_deinit(struct charlcd *lcd)
+{
+	struct charlcd_priv *priv = charlcd_to_priv(lcd);
+
+	if (lcd->ops->backlight) {
+		cancel_delayed_work_sync(&priv->bl_work);
+		lcd->ops->backlight(lcd, CHARLCD_OFF);
+	}
+}
+
 struct charlcd *charlcd_alloc(unsigned int drvdata_size)
 {
 	struct charlcd_priv *priv;
@@ -654,8 +664,10 @@ int charlcd_register(struct charlcd *lcd)
 		return ret;
 
 	ret = misc_register(&charlcd_dev);
-	if (ret)
+	if (ret) {
+		charlcd_deinit(lcd);
 		return ret;
+	}
 
 	the_charlcd = lcd;
 	register_reboot_notifier(&panel_notifier);
@@ -665,16 +677,11 @@ EXPORT_SYMBOL_GPL(charlcd_register);
 
 int charlcd_unregister(struct charlcd *lcd)
 {
-	struct charlcd_priv *priv = charlcd_to_priv(lcd);
-
 	unregister_reboot_notifier(&panel_notifier);
 	charlcd_puts(lcd, "\x0cLCD driver unloaded.\x1b[Lc\x1b[Lb\x1b[L-");
 	misc_deregister(&charlcd_dev);
 	the_charlcd = NULL;
-	if (lcd->ops->backlight) {
-		cancel_delayed_work_sync(&priv->bl_work);
-		priv->lcd.ops->backlight(&priv->lcd, CHARLCD_OFF);
-	}
+	charlcd_deinit(lcd);
 
 	return 0;
 }
-- 
2.50.1.windows.1

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

* Re: [PATCH v3] auxdisplay: charlcd: cancel backlight work on registration failure
  2026-08-15 10:59 [PATCH v3] auxdisplay: charlcd: cancel backlight work on registration failure Hongyan Xu
@ 2026-08-15 11:54 ` Miguel Ojeda
  2026-08-15 13:39 ` Geert Uytterhoeven
  2026-08-17  7:51 ` Andy Shevchenko
  2 siblings, 0 replies; 4+ messages in thread
From: Miguel Ojeda @ 2026-08-15 11:54 UTC (permalink / raw)
  To: Hongyan Xu
  Cc: Andy Shevchenko, Andy Shevchenko, Geert Uytterhoeven,
	Miguel Ojeda, linux-kernel, stable, Jianhao Xu, Lars Poeschel,
	Willy Tarreau

On Sat, Aug 15, 2026 at 1:00 PM Hongyan Xu <getshell@seu.edu.cn> wrote:
>
> Changes in v3:
> - Add Cc: stable@vger.kernel.org (Miguel).

Thanks! (Usually it is not needed to send a new version just to add a
tag -- it can be added by maintainers on apply)

Cheers,
Miguel

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

* Re: [PATCH v3] auxdisplay: charlcd: cancel backlight work on registration failure
  2026-08-15 10:59 [PATCH v3] auxdisplay: charlcd: cancel backlight work on registration failure Hongyan Xu
  2026-08-15 11:54 ` Miguel Ojeda
@ 2026-08-15 13:39 ` Geert Uytterhoeven
  2026-08-17  7:51 ` Andy Shevchenko
  2 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2026-08-15 13:39 UTC (permalink / raw)
  To: Hongyan Xu
  Cc: Andy Shevchenko, Andy Shevchenko, Miguel Ojeda, Miguel Ojeda,
	linux-kernel, stable, Jianhao Xu, Lars Poeschel, Willy Tarreau

On Sat, 15 Aug 2026 at 13:00, 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.
>
> Add charlcd_deinit() to cancel the delayed work and turn the backlight
> off. Use it for both registration rollback and normal unregistration.
>
> Fixes: 39f8ea46724e ("auxdisplay: charlcd: Extract character LCD core from misc/panel")
> Cc: stable@vger.kernel.org
> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
> ---
> Changes in v3:
> - Add Cc: stable@vger.kernel.org (Miguel).
>
> Changes in v2:
> - Factor the backlight cleanup into charlcd_deinit() and reuse it from
>   charlcd_unregister() (Andy, Geert).
> - Add the Fixes tag (Andy).

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v3] auxdisplay: charlcd: cancel backlight work on registration failure
  2026-08-15 10:59 [PATCH v3] auxdisplay: charlcd: cancel backlight work on registration failure Hongyan Xu
  2026-08-15 11:54 ` Miguel Ojeda
  2026-08-15 13:39 ` Geert Uytterhoeven
@ 2026-08-17  7:51 ` Andy Shevchenko
  2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-08-17  7:51 UTC (permalink / raw)
  To: Hongyan Xu
  Cc: Andy Shevchenko, Geert Uytterhoeven, Miguel Ojeda, Miguel Ojeda,
	linux-kernel, stable, Jianhao Xu, Lars Poeschel, Willy Tarreau

On Sat, Aug 15, 2026 at 06:59:50PM +0800, Hongyan Xu 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.
> 
> Add charlcd_deinit() to cancel the delayed work and turn the backlight
> off. Use it for both registration rollback and normal unregistration.

Pushed to my review and testing queue, thanks!

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2026-08-17  7:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-15 10:59 [PATCH v3] auxdisplay: charlcd: cancel backlight work on registration failure Hongyan Xu
2026-08-15 11:54 ` Miguel Ojeda
2026-08-15 13:39 ` Geert Uytterhoeven
2026-08-17  7:51 ` 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®