<< | Thread Index | >> ]    [ << | Date Index | >> ]

Subject: [PATCH] Deadlock under Linux 2.4
From: Olaf Titz <olaf,AT,bigred,DOT,inka,DOT,de>
Date: Thu, 19 Oct 2000 14:15:06 +0200

The attached patch (which should apply cleanly to CIPE 1.4.x with some
fuzz) fixes a deadlock in dynamic device allocation under Linux 2.4.
Anyone who uses 2.4 needs this. Looks like I'll have to make a 1.4.4
release RSN.

It also raises the limit on devices a bit, as some people really need
more than 100.

Olaf

--- device.c    2000/10/06 23:15:05     1.39
+++ device.c    2000/10/19 11:11:36
@@ -549,7 +544,6 @@
     memset(d->broadcast, 0xFF, ETH_ALEN);
     cc->dev.addr_len=ETH_ALEN;

-    rtnl_LOCK();
     e=register_netdevice(&(cc->dev));
     if (e<0) {
        kfree(cc);
@@ -560,7 +554,6 @@
         cc->cipe.owner=current->pid;
     }
     cipe_ctrls[n]=cc;
-    rtnl_UNLOCK();
     return e;
 }

@@ -574,14 +567,11 @@
         printk(KERN_WARNING DEVNAME ": Ouch: cipe_unalloc_dev() wrong 
struct\n");
         return;
     }
-    rtnl_LOCK();
     unregister_netdevice(&(cc->dev));
     cipe_ctrls[n]=NULL;
-    rtnl_UNLOCK();
     kfree(cc);
 }

-
 int init_module(void)
 {
     int e=cipe_check_kernel();
@@ -590,7 +580,11 @@

     /* sanity check on insmod-provided data */
     if (cipe_maxdev<1)  cipe_maxdev=1;
+#ifdef NO_DYNDEV
     if (cipe_maxdev>100) cipe_maxdev=100;
+#else
+    if (cipe_maxdev>10000) cipe_maxdev=10000;
+#endif

 #ifdef DEBUG
     printk(KERN_INFO
@@ -614,9 +608,13 @@
 #ifdef NO_DYNDEV
     {
         int i;
+       rtnl_LOCK();
         for (i=0; i<cipe_maxdev; ++i)
-            if ((e=cipe_alloc_dev(i)))
+            if ((e=cipe_alloc_dev(i))) {
+               rtnl_UNLOCK();
                 return e;
+           }
+       rtnl_UNLOCK();
         return 0;
     }
 #else
@@ -627,8 +625,10 @@
 void cleanup_module(void)
 {
     int i;
+    rtnl_LOCK();
     for (i=0; i<cipe_maxdev; ++i)
        cipe_unalloc_dev(i);
+    rtnl_UNLOCK();
     kfree(cipe_ctrls);
 }

=== end of patch ===





<< | Thread Index | >> ]    [ << | Date Index | >> ]