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

* Re: [PATCH] auxdisplay: charlcd: cancel backlight work on registration failure
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Miguel Ojeda @ 2026-07-19 15:53 UTC (permalink / raw)
  To: Hongyan Xu, Andy Shevchenko, Geert Uytterhoeven
  Cc: ojeda, linux-kernel, jianhao.xu, Lars Poeschel, Willy Tarreau

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

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

* Re: [PATCH] auxdisplay: charlcd: cancel backlight work on registration failure
  2026-07-19 15:53 ` Miguel Ojeda
@ 2026-08-12  8:37   ` Andy Shevchenko
  2026-08-12  8:50     ` Geert Uytterhoeven
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2026-08-12  8:37 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Hongyan Xu, Andy Shevchenko, Geert Uytterhoeven, ojeda,
	linux-kernel, jianhao.xu, Lars Poeschel, Willy Tarreau

On Sun, Jul 19, 2026 at 05:53:31PM +0200, Miguel Ojeda wrote:
> 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`.

Geert, are you okay with the change?
I have browsed the code and the report seems valid.

Hongyan, the patch adds the same piece that's already present in the
charlcd_unregister(). Can you split that to the helper function like
charlcd_bl_cancel_work()?

Also this needs a Fixes tag.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] auxdisplay: charlcd: cancel backlight work on registration failure
  2026-08-12  8:37   ` Andy Shevchenko
@ 2026-08-12  8:50     ` Geert Uytterhoeven
  2026-08-12  9:31       ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Geert Uytterhoeven @ 2026-08-12  8:50 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Miguel Ojeda, Hongyan Xu, Andy Shevchenko, ojeda, linux-kernel,
	jianhao.xu, Lars Poeschel, Willy Tarreau

On Wed, 12 Aug 2026 at 10:37, Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
> On Sun, Jul 19, 2026 at 05:53:31PM +0200, Miguel Ojeda wrote:
> > 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`.
>
> Geert, are you okay with the change?
> I have browsed the code and the report seems valid.

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

> Hongyan, the patch adds the same piece that's already present in the
> charlcd_unregister(). Can you split that to the helper function like
> charlcd_bl_cancel_work()?

Or charlcd_deinit(), as it basically undoes charlcd_init()?

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] 5+ messages in thread

* Re: [PATCH] auxdisplay: charlcd: cancel backlight work on registration failure
  2026-08-12  8:50     ` Geert Uytterhoeven
@ 2026-08-12  9:31       ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2026-08-12  9:31 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Miguel Ojeda, Hongyan Xu, Andy Shevchenko, ojeda, linux-kernel,
	jianhao.xu, Lars Poeschel, Willy Tarreau

On Wed, Aug 12, 2026 at 10:50:11AM +0200, Geert Uytterhoeven wrote:
> On Wed, 12 Aug 2026 at 10:37, Andy Shevchenko
> <andriy.shevchenko@intel.com> wrote:
> > On Sun, Jul 19, 2026 at 05:53:31PM +0200, Miguel Ojeda wrote:
> > > 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`.
> >
> > Geert, are you okay with the change?
> > I have browsed the code and the report seems valid.
> 
> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>

Thanks!

> > Hongyan, the patch adds the same piece that's already present in the
> > charlcd_unregister(). Can you split that to the helper function like
> > charlcd_bl_cancel_work()?
> 
> Or charlcd_deinit(), as it basically undoes charlcd_init()?

I am fine with either choice.

-- 
With Best Regards,
Andy Shevchenko



^ 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®