patch-2.4.12 linux/drivers/net/macsonic.c

Next file: linux/drivers/net/sk98lin/skge.c
Previous file: linux/drivers/net/at1700.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.11/linux/drivers/net/macsonic.c linux/drivers/net/macsonic.c
@@ -168,6 +168,8 @@
 	if ((lp->rba = (char *)
 	     kmalloc(SONIC_NUM_RRS * SONIC_RBSIZE, GFP_KERNEL | GFP_DMA)) == NULL) {
 		printk(KERN_ERR "%s: couldn't allocate receive buffers\n", dev->name);
+		kfree(lp->sonic_desc);
+		lp->sonic_desc = NULL;
 		return -ENOMEM;
 	}
 
@@ -322,7 +324,7 @@
 		/* methinks this will always be true but better safe than sorry */
 		if (dev->priv == NULL) {
 			dev->priv = kmalloc(sizeof(struct sonic_local), GFP_KERNEL);
-			if (!dev->priv) /* FIXME: kfree dev if necessary */
+			if (!dev->priv)
 				return -ENOMEM;
 		}
 	} else {
@@ -518,9 +520,14 @@
 
 	if (dev) {
 		dev = init_etherdev(dev, sizeof(struct sonic_local));
+		if (!dev)
+			return -ENOMEM;
 		/* methinks this will always be true but better safe than sorry */
-		if (dev->priv == NULL)
+		if (dev->priv == NULL) {
 			dev->priv = kmalloc(sizeof(struct sonic_local), GFP_KERNEL);
+			if (!dev->priv) /* FIXME: kfree dev if necessary */
+				return -ENOMEM;
+		}
 	} else {
 		dev = init_etherdev(NULL, sizeof(struct sonic_local));
 	}

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