patch-2.4.3 linux/drivers/net/mace.c

Next file: linux/drivers/net/macmace.c
Previous file: linux/drivers/net/mac89x0.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.2/linux/drivers/net/mace.c linux/drivers/net/mace.c
@@ -87,7 +87,7 @@
 /*
  * If we can't get a skbuff when we need it, we use this area for DMA.
  */
-static unsigned char dummy_buf[RX_BUFLEN+2];
+static unsigned char *dummy_buf;
 
 /* Bit-reverse one byte of an ethernet hardware address. */
 static inline int
@@ -106,7 +106,7 @@
 
 	for (mace = find_devices("mace"); mace != NULL; mace = mace->next)
 		mace_probe1(mace);
-	return 0;
+	return mace_devs? 0: -ENODEV;
 }
 
 static void __init mace_probe1(struct device_node *mace)
@@ -132,6 +132,14 @@
 		}
 	}
 
+	if (dummy_buf == NULL) {
+		dummy_buf = kmalloc(RX_BUFLEN+2, GFP_KERNEL);
+		if (dummy_buf == NULL) {
+			printk(KERN_ERR "MACE: couldn't allocate dummy buffer\n");
+			return;
+		}
+	}
+
 	dev = init_etherdev(0, PRIV_BYTES);
 	if (!dev)
 		return;
@@ -897,6 +905,10 @@
 
 	unregister_netdev(dev);
 	kfree(dev);
+    }
+    if (dummy_buf != NULL) {
+	kfree(dummy_buf);
+	dummy_buf = NULL;
     }
 }
 

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