Skip to content

Commit 7d98c63

Browse files
sudipm-mukherjeegregkh
authored andcommitted
staging: panel: fix stackdump
if we load the module, unload and then again try to load the module, we will get a stackdump. In the module_exit function we are unregistering the device and releasing the parport. So when we reach the detach function parport is already null and the unregister_reboot_notifier() is never called. When we again try to load the module it again tries register_reboot_notifier() and gives us a stackdump as its earlier registration is still not removed. It was caused by the commit bb046fe ('staging: panel: register reboot') Fix this by moving all the unregistering and releasing in the detach function, which should be the ideal case as the detach will be called if we try to unregister the driver or if the parport is removed. Fixes: bb046fe ('staging: panel: register reboot') Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 288ef56 commit 7d98c63

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

drivers/staging/panel/panel.c

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,8 +2250,28 @@ static void panel_detach(struct parport *port)
22502250
__func__, port->number, parport);
22512251
return;
22522252
}
2253+
if (scan_timer.function != NULL)
2254+
del_timer_sync(&scan_timer);
22532255

2254-
unregister_reboot_notifier(&panel_notifier);
2256+
if (pprt != NULL) {
2257+
if (keypad.enabled) {
2258+
misc_deregister(&keypad_dev);
2259+
keypad_initialized = 0;
2260+
}
2261+
2262+
if (lcd.enabled) {
2263+
panel_lcd_print("\x0cLCD driver " PANEL_VERSION
2264+
"\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-");
2265+
misc_deregister(&lcd_dev);
2266+
lcd.initialized = false;
2267+
}
2268+
2269+
/* TODO: free all input signals */
2270+
parport_release(pprt);
2271+
parport_unregister_device(pprt);
2272+
pprt = NULL;
2273+
unregister_reboot_notifier(&panel_notifier);
2274+
}
22552275
}
22562276

22572277
static struct parport_driver panel_driver = {
@@ -2384,28 +2404,6 @@ static int __init panel_init_module(void)
23842404

23852405
static void __exit panel_cleanup_module(void)
23862406
{
2387-
2388-
if (scan_timer.function != NULL)
2389-
del_timer_sync(&scan_timer);
2390-
2391-
if (pprt != NULL) {
2392-
if (keypad.enabled) {
2393-
misc_deregister(&keypad_dev);
2394-
keypad_initialized = 0;
2395-
}
2396-
2397-
if (lcd.enabled) {
2398-
panel_lcd_print("\x0cLCD driver " PANEL_VERSION
2399-
"\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-");
2400-
misc_deregister(&lcd_dev);
2401-
lcd.initialized = false;
2402-
}
2403-
2404-
/* TODO: free all input signals */
2405-
parport_release(pprt);
2406-
parport_unregister_device(pprt);
2407-
pprt = NULL;
2408-
}
24092407
parport_unregister_driver(&panel_driver);
24102408
}
24112409

0 commit comments

Comments
 (0)