All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] staging: panel: fix stackdump
@ 2015-05-12 11:15 Sudip Mukherjee
  2015-05-12 11:27 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Sudip Mukherjee @ 2015-05-12 11:15 UTC (permalink / raw)
  To: Willy Tarreau, Greg Kroah-Hartman; +Cc: devel, linux-kernel, Sudip Mukherjee

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
<bb046fef9668baf1c4744a3c7aba05e15e44c9ac>.
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.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---

v2: addded previous commit id to commit message

Faced this problem while working on the device-model code of
parallelport.

 drivers/staging/panel/panel.c | 44 +++++++++++++++++++++----------------------
 1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index 1d8ed8b..0046ee0 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -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);
 }
 
-- 
1.8.1.2


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

* Re: [PATCH v2] staging: panel: fix stackdump
  2015-05-12 11:15 [PATCH v2] staging: panel: fix stackdump Sudip Mukherjee
@ 2015-05-12 11:27 ` Dan Carpenter
  2015-05-12 11:50   ` Sudip Mukherjee
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2015-05-12 11:27 UTC (permalink / raw)
  To: Sudip Mukherjee; +Cc: Willy Tarreau, Greg Kroah-Hartman, devel, linux-kernel

On Tue, May 12, 2015 at 04:45:44PM +0530, Sudip Mukherjee wrote:
> 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
> <bb046fef9668baf1c4744a3c7aba05e15e44c9ac>.

The right format is:

commit bb046fef9668 ('staging: panel: register reboot')

It is in case human beings reading your description don't remember which
patch bb046fef9668 was.

> 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.
> 

We also have the Fixes: tag.

Fixes: bb046fef9668 ('staging: panel: register reboot')

> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>

regards,
dan carpenter


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

* Re: [PATCH v2] staging: panel: fix stackdump
  2015-05-12 11:27 ` Dan Carpenter
@ 2015-05-12 11:50   ` Sudip Mukherjee
  0 siblings, 0 replies; 3+ messages in thread
From: Sudip Mukherjee @ 2015-05-12 11:50 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Willy Tarreau, Greg Kroah-Hartman, devel, linux-kernel

On Tue, May 12, 2015 at 02:27:13PM +0300, Dan Carpenter wrote:
> On Tue, May 12, 2015 at 04:45:44PM +0530, Sudip Mukherjee wrote:
> > 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
> > <bb046fef9668baf1c4744a3c7aba05e15e44c9ac>.
> 
> The right format is:
> 
> commit bb046fef9668 ('staging: panel: register reboot')
> 
> It is in case human beings reading your description don't remember which
> patch bb046fef9668 was.
> 
> > 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.
> > 
> 
> We also have the Fixes: tag.
> 
> Fixes: bb046fef9668 ('staging: panel: register reboot')

ok, thanks.
I will send the v3 with the commit in correct format.

regards
sudip
> 
> > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> 
> regards,
> dan carpenter
> 

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

end of thread, other threads:[~2015-05-12 11:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-12 11:15 [PATCH v2] staging: panel: fix stackdump Sudip Mukherjee
2015-05-12 11:27 ` Dan Carpenter
2015-05-12 11:50   ` Sudip Mukherjee

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.