patch-2.3.99-pre6 linux/drivers/atm/ambassador.c

Next file: linux/drivers/atm/ambassador.h
Previous file: linux/drivers/atm/Makefile
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.99-pre5/linux/drivers/atm/ambassador.c linux/drivers/atm/ambassador.c
@@ -1251,10 +1251,15 @@
     }
   }
   
+  // prevent module unload while sleeping (kmalloc/down)
+  // doing this any earlier would complicate more error return paths
+  MOD_INC_USE_COUNT;
+  
   // get space for our vcc stuff
   vcc = kmalloc (sizeof(amb_vcc), GFP_KERNEL);
   if (!vcc) {
     PRINTK (KERN_ERR, "out of memory!");
+    MOD_DEC_USE_COUNT;
     return -ENOMEM;
   }
   atm_vcc->dev_data = (void *) vcc;
@@ -1340,7 +1345,6 @@
   // indicate readiness
   set_bit(ATM_VF_READY,&atm_vcc->flags);
   
-  MOD_INC_USE_COUNT;
   return 0;
 }
 
@@ -1420,7 +1424,9 @@
   
   // say the VPI/VCI is free again
   clear_bit(ATM_VF_ADDR,&atm_vcc->flags);
+
   MOD_DEC_USE_COUNT;
+  return;
 }
 
 /********** DebugIoctl **********/

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)