Messages in this thread Patch in this message | | | Date | Tue, 8 Aug 2000 11:32:56 -0300 | From | Arnaldo Carvalho de Melo <> | Subject | [PATCH] aironet4500_cs.c kmalloc checking |
| |
Hi,
Please apply this patch.
- Arnaldo
--- linux-2.4.0-test6-pre8/drivers/net/pcmcia/aironet4500_cs.c Fri Jul 28 06:34:44 2000 +++ linux-2.4.0-test6-pre8.acme/drivers/net/pcmcia/aironet4500_cs.c Tue Aug 8 11:28:40 2000 @@ -7,11 +7,14 @@ * * Revision 0.1 ,started 30.12.1998 * + * Revision 0.2 - Arnaldo Carvalho de Melo <acme@conectiva.com.br> + * 08/07/2000 - check kmalloc return in awc_attach, and only + * use memnset over dev if it was successfuly allocated. * */ static const char *awc_version = -"aironet4500_cs.c v0.1 1/1/99 Elmer Joandi, elmer@ylenurme.ee.\n"; +"aironet4500_cs.c v0.2 1/1/99 Elmer Joandi, elmer@ylenurme.ee.\n"; #include <linux/module.h> @@ -177,8 +180,17 @@ /* Create the PC card device object. */ link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); - memset(link, 0, sizeof(struct dev_link_t)); + if (!link) + return NULL; + link->dev = kmalloc(sizeof(struct dev_node_t), GFP_KERNEL); + + if (!link->dev) { + kfree(link); + return NULL; + } + + memset(link, 0, sizeof(struct dev_link_t)); memset(link->dev, 0, sizeof(struct dev_node_t)); link->release.function = &awc_release; @@ -199,7 +211,6 @@ /* Create the network device object. */ dev = kmalloc(sizeof(struct net_device ), GFP_KERNEL); - memset(dev,0,sizeof(struct net_device)); // dev = init_etherdev(0, sizeof(struct awc_private) ); if (!dev ) { printk(KERN_CRIT "out of mem on dev alloc \n"); @@ -209,6 +220,8 @@ }; dev->priv = kmalloc(sizeof(struct awc_private), GFP_KERNEL); if (!dev->priv ) {printk(KERN_CRIT "out of mem on dev priv alloc \n"); return NULL;}; + + memset(dev,0,sizeof(struct net_device)); memset(dev->priv,0,sizeof(struct awc_private)); // link->dev->minor = dev->minor; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |