patch-2.4.0-test6 linux/drivers/net/pcmcia/com20020_cs.c
Next file: linux/drivers/net/pcmcia/ray_cs.c
Previous file: linux/drivers/net/pcmcia/Makefile
Back to the patch index
Back to the overall index
- Lines: 72
- Date:
Wed Aug 9 13:51:40 2000
- Orig file:
v2.4.0-test5/linux/drivers/net/pcmcia/com20020_cs.c
- Orig date:
Thu Jul 27 17:38:00 2000
diff -u --recursive --new-file v2.4.0-test5/linux/drivers/net/pcmcia/com20020_cs.c linux/drivers/net/pcmcia/com20020_cs.c
@@ -21,6 +21,11 @@
* modified by SRC, incorporated herein by reference.
*
* **********************
+ * Changes:
+ * Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 08/08/2000
+ * - reorganize kmallocs in com20020_attach, checking all for failure
+ * and releasing the previous allocations if one fails
+ * **********************
*
* For more details, see drivers/net/arcnet.c
*
@@ -198,7 +203,24 @@
link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
if (!link)
return NULL;
+
+ info = kmalloc(sizeof(struct com20020_dev_t), GFP_KERNEL);
+ if (!info)
+ goto fail_alloc_info;
+
+ lp = kmalloc(sizeof(struct arcnet_local), GFP_KERNEL);
+ if (!lp)
+ goto fail_alloc_lp;
+
+ dev = dev_alloc("arc%d", &ret);
+ if (!dev)
+ goto fail_alloc_dev;
+
+ memset(info, 0, sizeof(struct com20020_dev_t));
+ memset(lp, 0, sizeof(struct arcnet_local));
memset(link, 0, sizeof(struct dev_link_t));
+ dev->priv = lp;
+
link->release.function = &com20020_release;
link->release.data = (u_long)link;
link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
@@ -216,19 +238,6 @@
link->conf.IntType = INT_MEMORY_AND_IO;
link->conf.Present = PRESENT_OPTION;
- info = kmalloc(sizeof(struct com20020_dev_t), GFP_KERNEL);
- if (!info)
- return NULL;
- memset(info, 0, sizeof(struct com20020_dev_t));
-
- dev = dev_alloc("arc%d", &ret);
- if (!dev)
- return NULL;
- lp = dev->priv = kmalloc(sizeof(struct arcnet_local), GFP_KERNEL);
- if (!lp)
- return NULL;
- memset(lp, 0, sizeof(struct arcnet_local));
-
/* fill in our module parameters as defaults */
dev->dev_addr[0] = node;
lp->timeout = timeout;
@@ -260,6 +269,14 @@
}
return link;
+
+fail_alloc_dev:
+ kfree(lp);
+fail_alloc_lp:
+ kfree(info);
+fail_alloc_info:
+ kfree(link);
+ return NULL;
} /* com20020_attach */
/*======================================================================
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)