Subject: uml net: revert introduction of private buffer Avoid using the temporary buffer introduced by previous patch to hold the device name. Btw, avoid leaking device on an error path. Other error paths may need cleanup. Signed-off-by: Paolo 'Blaisorblade' Giarrusso Index: linux-2.6.git/arch/um/drivers/net_kern.c =================================================================== --- linux-2.6.git.orig/arch/um/drivers/net_kern.c +++ linux-2.6.git/arch/um/drivers/net_kern.c @@ -349,15 +349,20 @@ static int eth_configure(int n, void *in struct net_device *dev; struct uml_net_private *lp; int save, err, size; - char name[sizeof(dev->name)]; size = transport->private_size + sizeof(struct uml_net_private) + sizeof(((struct uml_net_private *) 0)->user); device = kzalloc(sizeof(*device), GFP_KERNEL); if (device == NULL) { - printk(KERN_ERR "eth_configure failed to allocate uml_net\n"); - return(1); + printk(KERN_ERR "eth_configure failed to allocate struct uml_net\n"); + return 1; + } + + dev = alloc_etherdev(size); + if (dev == NULL) { + printk(KERN_ERR "eth_configure: failed to allocate struct net_device for eth%d\n", n); + return 1; } INIT_LIST_HEAD(&device->list); @@ -371,9 +376,9 @@ static int eth_configure(int n, void *in * netdevice, that is OK, register_netdev{,ice}() will notice this * and fail. */ - snprintf(name, sizeof(name), "eth%d", n); + snprintf(dev->name, sizeof(dev->name), "eth%d", n); - setup_etheraddr(mac, device->mac, name); + setup_etheraddr(mac, device->mac, dev->name); printk(KERN_INFO "Netdevice %d ", n); printk("(%02x:%02x:%02x:%02x:%02x:%02x) ", @@ -381,11 +386,6 @@ static int eth_configure(int n, void *in device->mac[2], device->mac[3], device->mac[4], device->mac[5]); printk(": "); - dev = alloc_etherdev(size); - if (dev == NULL) { - printk(KERN_ERR "eth_configure: failed to allocate device\n"); - return 1; - } lp = dev->priv; /* This points to the transport private data. It's still clear, but we @@ -403,7 +403,6 @@ static int eth_configure(int n, void *in platform_device_register(&device->pdev); SET_NETDEV_DEV(dev,&device->pdev.dev); - strcpy(dev->name, name); device->dev = dev; (*transport->kern->init)(dev, init); @@ -426,8 +425,12 @@ static int eth_configure(int n, void *in rtnl_unlock(); if (err) { device->dev = NULL; - /* XXX: should we call ->remove() here? */ + /* XXX: should we call ->remove() here? + * IMHO no, kern->remove does + * not exist because allocations are done here only, and + * user->init has not been called yet.*/ free_netdev(dev); + kfree(device); return 1; }