Skip to contentSkip to conversation

auxdisplay: charlcd: cancel backlight work on registration failure

PATCH Superseded Hongyan Xu 4 participants 5 messages Jul 19 – Aug 12 Auxiliary display drivers

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Hongyan Xu

author
#0 lore raw

PATCH 1/1 auxdisplay: charlcd: cancel backlight work on registration failure

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.

---
 drivers/auxdisplay/charlcd.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/auxdisplay/charlcd.c +7 -1
index 6d309e4..92530e0 100644
@@ -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);
Signature · 1 line
2.50.1.windows.1
#1 lore raw
Quoted 10 lines · 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.

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

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

#2 lore raw
Quoted 10 lines · Miguel Ojeda
Quoted 9 lines · 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.

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

Quoted 6 lines
Quoted 1 line

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.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
reviewer Reviewed-by
#3 lore raw
Quoted 13 lines · Andy Shevchenko
Quoted 12 lines · Miguel Ojeda
Quoted 10 lines · 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.

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

Quoted 7 lines
Quoted 4 lines

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.

Quoted 3 lines

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

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
#4 lore raw
Quoted 17 lines · Geert Uytterhoeven
Quoted 15 lines · Andy Shevchenko
Quoted 14 lines · Miguel Ojeda
Quoted 10 lines · 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.

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

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

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

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.

Thanks!

Quoted 5 lines
Quoted 3 lines

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.

Signature · 2 lines
With Best Regards,
Andy Shevchenko