Commit 6e634db3 authored by François Romieu's avatar François Romieu Committed by Stephen Hemminger

[PATCH] 2.6.0-test6 - more free_netdev() conversion

Compiles ok (with true .o generated, yeah). Please review.

free_netdev() of devices allocated through use of alloc_netdev().
Though baroque, drivers/net/3c515.c now uses alloc_etherdev().


 drivers/net/3c515.c   |   23 ++++++++++++-----------
 drivers/net/defxx.c   |    2 +-
 drivers/net/dummy.c   |    2 +-
 drivers/net/eql.c     |    2 +-
 drivers/net/ns83820.c |    2 +-
 drivers/net/plip.c    |   14 ++++++++++----
 drivers/net/shaper.c  |   11 ++++++++---
 drivers/net/tun.c     |   18 +++++++++---------
 9 files changed, 43 insertions(+), 31 deletions(-)
parent 8129fc9c
...@@ -569,14 +569,13 @@ static struct net_device *corkscrew_found_device(struct net_device *dev, ...@@ -569,14 +569,13 @@ static struct net_device *corkscrew_found_device(struct net_device *dev,
#ifdef MODULE #ifdef MODULE
/* Allocate and fill new device structure. */ /* Allocate and fill new device structure. */
int dev_size = sizeof(struct net_device) + sizeof(struct corkscrew_private) + 15; /* Pad for alignment */ int dev_size = sizeof(struct corkscrew_private);
dev = (struct net_device *) kmalloc(dev_size, GFP_KERNEL); dev = alloc_etherdev(dev_size);
if (!dev) if (!dev)
return NULL; goto err_out;
memset(dev, 0, dev_size); memset(dev, 0, dev_size);
/* Align the Rx and Tx ring entries. */
dev->priv = (void *) (((long) dev + sizeof(struct net_device) + 15) & ~15);
vp = (struct corkscrew_private *) dev->priv; vp = (struct corkscrew_private *) dev->priv;
dev->base_addr = ioaddr; dev->base_addr = ioaddr;
dev->irq = irq; dev->irq = irq;
...@@ -593,19 +592,16 @@ static struct net_device *corkscrew_found_device(struct net_device *dev, ...@@ -593,19 +592,16 @@ static struct net_device *corkscrew_found_device(struct net_device *dev,
vp->full_duplex = 0; vp->full_duplex = 0;
vp->bus_master = 0; vp->bus_master = 0;
} }
ether_setup(dev);
vp->next_module = root_corkscrew_dev; vp->next_module = root_corkscrew_dev;
root_corkscrew_dev = dev; root_corkscrew_dev = dev;
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
if (register_netdev(dev) != 0) { if (register_netdev(dev) < 0)
kfree(dev); goto err_free_dev;
return NULL;
}
#else /* not a MODULE */ #else /* not a MODULE */
/* Caution: quad-word alignment required for rings! */ /* Caution: quad-word alignment required for rings! */
dev->priv = kmalloc(sizeof(struct corkscrew_private), GFP_KERNEL); dev->priv = kmalloc(sizeof(struct corkscrew_private), GFP_KERNEL);
if (!dev->priv) if (!dev->priv)
return NULL; goto err_out;
memset(dev->priv, 0, sizeof(struct corkscrew_private)); memset(dev->priv, 0, sizeof(struct corkscrew_private));
dev = init_etherdev(dev, sizeof(struct corkscrew_private)); dev = init_etherdev(dev, sizeof(struct corkscrew_private));
dev->base_addr = ioaddr; dev->base_addr = ioaddr;
...@@ -627,6 +623,11 @@ static struct net_device *corkscrew_found_device(struct net_device *dev, ...@@ -627,6 +623,11 @@ static struct net_device *corkscrew_found_device(struct net_device *dev,
corkscrew_probe1(dev); corkscrew_probe1(dev);
#endif /* MODULE */ #endif /* MODULE */
return dev; return dev;
err_free_dev:
free_netdev(dev);
err_out:
return NULL;
} }
static int corkscrew_probe1(struct net_device *dev) static int corkscrew_probe1(struct net_device *dev)
......
...@@ -491,7 +491,7 @@ static int __devinit dfx_init_one_pci_or_eisa(struct pci_dev *pdev, long ioaddr) ...@@ -491,7 +491,7 @@ static int __devinit dfx_init_one_pci_or_eisa(struct pci_dev *pdev, long ioaddr)
err_out_region: err_out_region:
release_region(ioaddr, pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN); release_region(ioaddr, pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN);
err_out: err_out:
kfree(dev); free_netdev(dev);
return err; return err;
} }
......
...@@ -96,7 +96,7 @@ static int __init dummy_init_module(void) ...@@ -96,7 +96,7 @@ static int __init dummy_init_module(void)
return -ENOMEM; return -ENOMEM;
if ((err = register_netdev(dev_dummy))) { if ((err = register_netdev(dev_dummy))) {
kfree(dev_dummy); free_netdev(dev_dummy);
dev_dummy = NULL; dev_dummy = NULL;
} }
return err; return err;
......
...@@ -600,7 +600,7 @@ static int __init eql_init_module(void) ...@@ -600,7 +600,7 @@ static int __init eql_init_module(void)
err = register_netdev(dev_eql); err = register_netdev(dev_eql);
if (err) if (err)
kfree(dev_eql); free_netdev(dev_eql);
return err; return err;
} }
......
...@@ -2034,7 +2034,7 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_ ...@@ -2034,7 +2034,7 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
pci_free_consistent(pci_dev, 4 * DESC_SIZE * NR_RX_DESC, dev->rx_info.descs, dev->rx_info.phy_descs); pci_free_consistent(pci_dev, 4 * DESC_SIZE * NR_RX_DESC, dev->rx_info.descs, dev->rx_info.phy_descs);
pci_disable_device(pci_dev); pci_disable_device(pci_dev);
out_free: out_free:
kfree(dev); free_netdev(&dev->net_dev);
pci_set_drvdata(pci_dev, NULL); pci_set_drvdata(pci_dev, NULL);
out: out:
return err; return err;
......
...@@ -1306,17 +1306,23 @@ static void plip_attach (struct parport *port) ...@@ -1306,17 +1306,23 @@ static void plip_attach (struct parport *port)
if (!nl->pardev) { if (!nl->pardev) {
printk(KERN_ERR "%s: parport_register failed\n", name); printk(KERN_ERR "%s: parport_register failed\n", name);
kfree(dev); goto err_free_dev;
return; return;
} }
if (register_netdev(dev)) { if (register_netdev(dev)) {
printk(KERN_ERR "%s: network register failed\n", name); printk(KERN_ERR "%s: network register failed\n", name);
kfree(dev); goto err_parport_unregister;
} else {
dev_plip[unit++] = dev;
} }
dev_plip[unit++] = dev;
} }
return;
err_parport_unregister:
parport_unregister_device(nl->pardev);
err_free_dev:
free_netdev(dev);
return;
} }
/* plip_detach() is called (by the parport code) when a port is /* plip_detach() is called (by the parport code) when a port is
......
...@@ -718,8 +718,10 @@ static int __init shaper_init(void) ...@@ -718,8 +718,10 @@ static int __init shaper_init(void)
if (!dev) if (!dev)
break; break;
if (register_netdev(dev)) if (register_netdev(dev)) {
free_netdev(dev);
break; break;
}
devs[i] = dev; devs[i] = dev;
shapers_registered++; shapers_registered++;
...@@ -737,9 +739,12 @@ static void __exit shaper_exit (void) ...@@ -737,9 +739,12 @@ static void __exit shaper_exit (void)
{ {
int i; int i;
for (i = 0; i < shapers_registered; i++) for (i = 0; i < shapers_registered; i++) {
if (devs[i]) if (devs[i]) {
unregister_netdev(devs[i]); unregister_netdev(devs[i]);
free_netdev(devs[i]);
}
}
kfree(devs); kfree(devs);
devs = NULL; devs = NULL;
......
...@@ -377,6 +377,7 @@ static struct tun_struct *tun_get_by_name(const char *name) ...@@ -377,6 +377,7 @@ static struct tun_struct *tun_get_by_name(const char *name)
static int tun_set_iff(struct file *file, struct ifreq *ifr) static int tun_set_iff(struct file *file, struct ifreq *ifr)
{ {
struct tun_struct *tun; struct tun_struct *tun;
struct net_device *dev;
int err; int err;
tun = tun_get_by_name(ifr->ifr_name); tun = tun_get_by_name(ifr->ifr_name);
...@@ -394,7 +395,6 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr) ...@@ -394,7 +395,6 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr)
else { else {
char *name; char *name;
unsigned long flags = 0; unsigned long flags = 0;
struct net_device *dev;
err = -EINVAL; err = -EINVAL;
...@@ -424,16 +424,13 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr) ...@@ -424,16 +424,13 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr)
if (strchr(dev->name, '%')) { if (strchr(dev->name, '%')) {
err = dev_alloc_name(dev, dev->name); err = dev_alloc_name(dev, dev->name);
if (err < 0) { if (err < 0)
kfree(dev); goto err_free_dev;
goto failed;
}
} }
if ((err = register_netdevice(tun->dev))) { err = register_netdevice(tun->dev);
kfree(dev); if (err < 0)
goto failed; goto err_free_dev;
}
list_add(&tun->list, &tun_dev_list); list_add(&tun->list, &tun_dev_list);
} }
...@@ -451,6 +448,9 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr) ...@@ -451,6 +448,9 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr)
strcpy(ifr->ifr_name, tun->dev->name); strcpy(ifr->ifr_name, tun->dev->name);
return 0; return 0;
err_free_dev:
free_netdev(dev);
failed: failed:
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment