patch-2.3.4 linux/drivers/net/net_init.c

Next file: linux/drivers/net/smc-ultra.c
Previous file: linux/drivers/net/lapbether.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.3/linux/drivers/net/net_init.c linux/drivers/net/net_init.c
@@ -91,9 +91,11 @@
 		for (i = 0; i < MAX_ETH_CARDS; ++i)
 			if (ethdev_index[i] == NULL) {
 				sprintf(pname, "eth%d", i);
-				for (cur_dev = dev_base; cur_dev; cur_dev = cur_dev->next)
+				read_lock_bh(&dev_base_lock);
+				for (cur_dev = dev_base; cur_dev; cur_dev = cur_dev->next) {
 					if (strcmp(pname, cur_dev->name) == 0) {
 						dev = cur_dev;
+						read_unlock_bh(&dev_base_lock);
 						dev->init = NULL;
 						sizeof_priv = (sizeof_priv + 3) & ~3;
 						dev->priv = sizeof_priv
@@ -102,6 +104,8 @@
 						if (dev->priv) memset(dev->priv, 0, sizeof_priv);
 						goto found;
 					}
+				}
+				read_unlock_bh(&dev_base_lock);
 			}
 
 		alloc_size &= ~3;		/* Round to dword boundary. */
@@ -209,9 +213,11 @@
 		for (i = 0; i < MAX_HIP_CARDS; ++i)
 			if (hipdev_index[i] == NULL) {
 				sprintf(pname, "hip%d", i);
-				for (cur_dev = dev_base; cur_dev; cur_dev = cur_dev->next)
+				read_lock_bh(&dev_base_lock);
+				for (cur_dev = dev_base; cur_dev; cur_dev = cur_dev->next) {
 					if (strcmp(pname, cur_dev->name) == 0) {
 						dev = cur_dev;
+						read_unlock_bh(&dev_base_lock);
 						dev->init = NULL;
 						sizeof_priv = (sizeof_priv + 3) & ~3;
 						dev->priv = sizeof_priv
@@ -220,6 +226,8 @@
 						if (dev->priv) memset(dev->priv, 0, sizeof_priv);
 						goto hipfound;
 					}
+				}
+				read_unlock_bh(&dev_base_lock);
 			}
 
 		alloc_size &= ~3;		/* Round to dword boundary. */
@@ -536,9 +544,11 @@
 		for (i = 0; i < MAX_TR_CARDS; ++i)
 			if (trdev_index[i] == NULL) {
 				sprintf(pname, "tr%d", i);
-				for (cur_dev = dev_base; cur_dev; cur_dev = cur_dev->next)
+				read_lock_bh(&dev_base_lock);
+				for (cur_dev = dev_base; cur_dev; cur_dev = cur_dev->next) {
 					if (strcmp(pname, cur_dev->name) == 0) {
 						dev = cur_dev;
+						read_unlock_bh(&dev_base_lock);
 						dev->init = NULL;
 						sizeof_priv = (sizeof_priv + 3) & ~3;
 						dev->priv = sizeof_priv
@@ -547,6 +557,8 @@
 						if (dev->priv) memset(dev->priv, 0, sizeof_priv);
 						goto trfound;
 					}
+				}
+				read_unlock_bh(&dev_base_lock);
 			}
 
 		alloc_size &= ~3;		/* Round to dword boundary. */

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