netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] handle slip module unload race better.
       [not found] ` <20030612.145803.112592736.davem@redhat.com>
@ 2003-06-12 23:12   ` Stephen Hemminger
  2003-06-13  0:55     ` David S. Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2003-06-12 23:12 UTC (permalink / raw)
  To: David S. Miller; +Cc: viro, jgarzik, netdev

On Thu, 12 Jun 2003 14:58:03 -0700 (PDT)
"David S. Miller" <davem@redhat.com> wrote:

>    From: Stephen Hemminger <shemminger@osdl.org>
>    Date: Thu, 12 Jun 2003 13:27:14 -0700
> 
>    The following won't work.
>    
>  ...
>    				unregister_netdev(&slc->dev);
>    				if (slc->ctrl.tty) {
>    					printk(KERN_ERR "%s: tty discipline is still running\n", slc->dev.name);
>    					/* Pin module forever */
>    					MOD_INC_USE_COUNT;
>    
>    Because it is in the exit code for the module, and by that time
>    the module code has decided it is going to remove it and no
>    longer looks at the ref count.  Sorry, don't have a patch to
>    fix since this is related more to the problematic tty code, 
>    than the network code.
>    
> I think a reasonable thing for it to do is leak the netdevice
> and print a message when this happens.

Okay, this patch does that. I could start and unload slip, but could
not actually trigger the failure.

diff -Nru a/drivers/net/slip.c b/drivers/net/slip.c
--- a/drivers/net/slip.c	Thu Jun 12 16:10:30 2003
+++ b/drivers/net/slip.c	Thu Jun 12 16:10:30 2003
@@ -1381,27 +1381,23 @@
 			local_bh_enable();
 		} while (busy && time_before(jiffies, timeout));
 
-		busy = 0;
 		for (i = 0; i < slip_maxdev; i++) {
 			struct slip_ctrl *slc = slip_ctrls[i];
 			if (slc) {
 				unregister_netdev(&slc->dev);
 				if (slc->ctrl.tty) {
 					printk(KERN_ERR "%s: tty discipline is still running\n", slc->dev.name);
-					/* Pin module forever */
-					MOD_INC_USE_COUNT;
-					busy++;
-					continue;
+					/* Intentionally leak the control block. */
+				} else {
+					sl_free_bufs(&slc->ctrl);
+					kfree(slc);
 				}
-				sl_free_bufs(&slc->ctrl);
-				kfree(slc);
 				slip_ctrls[i] = NULL;
 			}
 		}
-		if (!busy) {
-			kfree(slip_ctrls);
-			slip_ctrls = NULL;
-		}
+
+		kfree(slip_ctrls);
+		slip_ctrls = NULL;
 	}
 	if ((i = tty_register_ldisc(N_SLIP, NULL)))
 	{

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

* Re: [PATCH] handle slip module unload race better.
  2003-06-12 23:12   ` [PATCH] handle slip module unload race better Stephen Hemminger
@ 2003-06-13  0:55     ` David S. Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2003-06-13  0:55 UTC (permalink / raw)
  To: shemminger; +Cc: viro, jgarzik, netdev

   From: Stephen Hemminger <shemminger@osdl.org>
   Date: Thu, 12 Jun 2003 16:12:43 -0700
   
   Okay, this patch does that. I could start and unload slip, but could
   not actually trigger the failure.

Applied, thanks.

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

end of thread, other threads:[~2003-06-13  0:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20030612132714.6b8e1267.shemminger@osdl.org>
     [not found] ` <20030612.145803.112592736.davem@redhat.com>
2003-06-12 23:12   ` [PATCH] handle slip module unload race better Stephen Hemminger
2003-06-13  0:55     ` David S. Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).