patch-2.3.50 linux/drivers/net/net_init.c
Next file: linux/drivers/net/pcmcia/aironet4500_cs.c
Previous file: linux/drivers/net/ncr885e.c
Back to the patch index
Back to the overall index
- Lines: 30
- Date:
Fri Mar 3 12:54:45 2000
- Orig file:
v2.3.49/linux/drivers/net/net_init.c
- Orig date:
Sun Feb 20 21:12:39 2000
diff -u --recursive --new-file v2.3.49/linux/drivers/net/net_init.c linux/drivers/net/net_init.c
@@ -69,18 +69,24 @@
static struct net_device *init_alloc_dev(int sizeof_priv)
{
struct net_device *dev;
- int alloc_size = sizeof(struct net_device) + IFNAMSIZ
- + sizeof_priv + 3;
- alloc_size &= ~3; /* Round to dword boundary. */
- dev = (struct net_device *)kmalloc(alloc_size, GFP_KERNEL);
- if(dev==NULL)
+ int alloc_size;
+
+ /* 32-byte alignment */
+ alloc_size = sizeof (*dev) + IFNAMSIZ + sizeof_priv + 31;
+ alloc_size &= ~31;
+
+ dev = (struct net_device *) kmalloc (alloc_size, GFP_KERNEL);
+ if (dev == NULL)
{
printk(KERN_ERR "alloc_dev: Unable to allocate device memory.\n");
return NULL;
}
+
memset(dev, 0, alloc_size);
+
if (sizeof_priv)
dev->priv = (void *) (dev + 1);
+
dev->name = sizeof_priv + (char *)(dev + 1);
return dev;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)