auxdisplay: charlcd: cancel backlight work on registration failure
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
@@ -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
Quoted 10 lines · Hongyan Xu
With
CONFIG_CHARLCD_BL_FLASH,charlcd_init()schedulesbl_workbeforecharlcd_register()callsmisc_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 <[email protected]>
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
Quoted 10 lines · Miguel Ojeda
Quoted 9 lines · Hongyan Xu
With
CONFIG_CHARLCD_BL_FLASH,charlcd_init()schedulesbl_workbeforecharlcd_register()callsmisc_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
Signed-off-by Hongyan Xu <[email protected]>I think you may have used an out-of-date
MAINTAINERSfile...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
Quoted 13 lines · Andy Shevchenko
Quoted 12 lines · Miguel Ojeda
Quoted 10 lines · Hongyan Xu
With
CONFIG_CHARLCD_BL_FLASH,charlcd_init()schedulesbl_workbeforecharlcd_register()callsmisc_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 <[email protected]>
Quoted 7 lines
Quoted 4 lines
I think you may have used an out-of-date
MAINTAINERSfile...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 likecharlcd_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
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()schedulesbl_workbeforecharlcd_register()callsmisc_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 <[email protected]>I think you may have used an out-of-date
MAINTAINERSfile...
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.Reviewed-by Geert Uytterhoeven <[email protected]>
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 likecharlcd_bl_cancel_work()?Or
charlcd_deinit(), as it basically undoescharlcd_init()?
I am fine with either choice.
Signature · 2 lines
With Best Regards, Andy Shevchenko