staging: panel: fix stackdump
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>
Tue, 12 May 2015 12:06:08 +0000 (17:36 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 24 May 2015 20:35:25 +0000 (13:35 -0700)
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 bb046fef9668 ('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: bb046fef9668 ('staging: panel: register reboot')
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/panel/panel.c

index 1d8ed8b35375dabf286daa0e394e9a5ec22bc231..0046ee0af8b952bf2793649bb343c1d821c4bdd7 100644 (file)
@@ -2250,8 +2250,28 @@ static void panel_detach(struct parport *port)
                       __func__, port->number, parport);
                return;
        }
+       if (scan_timer.function != NULL)
+               del_timer_sync(&scan_timer);
 
-       unregister_reboot_notifier(&panel_notifier);
+       if (pprt != NULL) {
+               if (keypad.enabled) {
+                       misc_deregister(&keypad_dev);
+                       keypad_initialized = 0;
+               }
+
+               if (lcd.enabled) {
+                       panel_lcd_print("\x0cLCD driver " PANEL_VERSION
+                                       "\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-");
+                       misc_deregister(&lcd_dev);
+                       lcd.initialized = false;
+               }
+
+               /* TODO: free all input signals */
+               parport_release(pprt);
+               parport_unregister_device(pprt);
+               pprt = NULL;
+               unregister_reboot_notifier(&panel_notifier);
+       }
 }
 
 static struct parport_driver panel_driver = {
@@ -2384,28 +2404,6 @@ static int __init panel_init_module(void)
 
 static void __exit panel_cleanup_module(void)
 {
-
-       if (scan_timer.function != NULL)
-               del_timer_sync(&scan_timer);
-
-       if (pprt != NULL) {
-               if (keypad.enabled) {
-                       misc_deregister(&keypad_dev);
-                       keypad_initialized = 0;
-               }
-
-               if (lcd.enabled) {
-                       panel_lcd_print("\x0cLCD driver " PANEL_VERSION
-                                       "\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-");
-                       misc_deregister(&lcd_dev);
-                       lcd.initialized = false;
-               }
-
-               /* TODO: free all input signals */
-               parport_release(pprt);
-               parport_unregister_device(pprt);
-               pprt = NULL;
-       }
        parport_unregister_driver(&panel_driver);
 }