diff options
| author | Jeff Garzik <jgarzik@redhat.com> | 2004-01-19 08:44:37 -0500 |
|---|---|---|
| committer | Jeff Garzik <jgarzik@redhat.com> | 2004-01-19 08:44:37 -0500 |
| commit | c2ba4cf883d7e7bed77555dd563623424bccbe73 (patch) | |
| tree | fd67c33b2918eb49745e94198238af9674b8fa96 | |
| parent | c4e1d17e57d4c8768c17c61acf6d70be49f86ff4 (diff) | |
| parent | 60964cda04b35fc5b7449ae052cc08604507a5c5 (diff) | |
Merge redhat.com:/spare/repo/netdev-2.6/netdev-alloc-6
into redhat.com:/spare/repo/netdev-2.6/netdev-alloc-7
52 files changed, 545 insertions, 583 deletions
diff --git a/arch/cris/arch-v10/drivers/ethernet.c b/arch/cris/arch-v10/drivers/ethernet.c index 6b9b40634da9..943db0b99803 100644 --- a/arch/cris/arch-v10/drivers/ethernet.c +++ b/arch/cris/arch-v10/drivers/ethernet.c @@ -482,7 +482,7 @@ etrax_ethernet_init(void) /* Register device */ err = register_netdev(dev); if (err) { - kfree(dev); + free_netdev(dev); return err; } diff --git a/arch/ia64/hp/sim/simeth.c b/arch/ia64/hp/sim/simeth.c index 1f5cdce1e966..f51225465fee 100644 --- a/arch/ia64/hp/sim/simeth.c +++ b/arch/ia64/hp/sim/simeth.c @@ -224,7 +224,7 @@ simeth_probe1(void) err = register_netdev(dev); if (err) { - kfree(dev); + free_netdev(dev); return err; } diff --git a/arch/ppc/8260_io/enet.c b/arch/ppc/8260_io/enet.c index 84bb884c32e4..b6dd2352ffcb 100644 --- a/arch/ppc/8260_io/enet.c +++ b/arch/ppc/8260_io/enet.c @@ -851,7 +851,7 @@ static int __init scc_enet_init(void) err = register_netdev(dev); if (err) { - kfree(dev); + free_netdev(dev); return err; } diff --git a/arch/ppc/8260_io/fcc_enet.c b/arch/ppc/8260_io/fcc_enet.c index 8cb8121e6c8d..226214c66f15 100644 --- a/arch/ppc/8260_io/fcc_enet.c +++ b/arch/ppc/8260_io/fcc_enet.c @@ -1371,7 +1371,7 @@ static int __init fec_enet_init(void) err = register_netdev(dev); if (err) { - kfree(dev); + free_netdev(dev); return err; } diff --git a/arch/ppc/8xx_io/enet.c b/arch/ppc/8xx_io/enet.c index ca316478dadd..2f45f3456251 100644 --- a/arch/ppc/8xx_io/enet.c +++ b/arch/ppc/8xx_io/enet.c @@ -949,7 +949,7 @@ static int __init scc_enet_init(void) err = register_netdev(dev); if (err) { - kfree(dev); + free_netdev(dev); return err; } diff --git a/arch/ppc/8xx_io/fec.c b/arch/ppc/8xx_io/fec.c index 5701dee523ce..5c7c914f84ea 100644 --- a/arch/ppc/8xx_io/fec.c +++ b/arch/ppc/8xx_io/fec.c @@ -1748,7 +1748,7 @@ static int __init fec_enet_init(void) err = register_netdev(dev); if (err) { - kfree(dev); + free_netdev(dev); return err; } diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c index d8f7468ae9e2..4c2ee09b02a1 100644 --- a/arch/um/drivers/net_kern.c +++ b/arch/um/drivers/net_kern.c @@ -358,8 +358,12 @@ static int eth_configure(int n, void *init, char *mac, rtnl_lock(); err = register_netdevice(dev); rtnl_unlock(); - if (err) + if (err) { + device->dev = NULL; + /* XXX: should we call ->remove() here? */ + free_netdev(dev); return 1; + } lp = dev->priv; INIT_LIST_HEAD(&lp->list); diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c index 1a66c5723fec..5cb7ae9559c2 100644 --- a/drivers/isdn/i4l/isdn_ppp.c +++ b/drivers/isdn/i4l/isdn_ppp.c @@ -1125,12 +1125,15 @@ isdn_ppp_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) return -EINVAL; switch (cmd) { + +#define PPP_VERSION "2.3.7" case SIOCGPPPVER: r = (char *) ifr->ifr_ifru.ifru_data; len = strlen(PPP_VERSION) + 1; if (copy_to_user(r, PPP_VERSION, len)) error = -EFAULT; break; + case SIOCGPPPSTATS: error = isdn_ppp_dev_ioctl_stats(ifr, dev); break; diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c index 013cd4de02e5..4f9a531e76a1 100644 --- a/drivers/media/dvb/dvb-core/dvb_net.c +++ b/drivers/media/dvb/dvb-core/dvb_net.c @@ -523,7 +523,8 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid) net->base_addr = pid; if ((result = register_netdev(net)) < 0) { - kfree(net); + dvbnet->device[if_num] = NULL; + free_netdev(net); return result; } @@ -545,6 +546,7 @@ static int dvb_net_remove_if(struct dvb_net *dvbnet, int num) flush_scheduled_work(); unregister_netdev(net); dvbnet->state[num]=0; + dvbnet->device[num] = NULL; free_netdev(net); return 0; diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c index 32a57101f0d5..da778b0f1a9d 100644 --- a/drivers/message/fusion/mptlan.c +++ b/drivers/message/fusion/mptlan.c @@ -1437,7 +1437,7 @@ mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum) SET_MODULE_OWNER(dev); if (register_netdev(dev) != 0) { - kfree(dev); + free_netdev(dev); dev = NULL; } return dev; diff --git a/drivers/net/3c509.c b/drivers/net/3c509.c index 6851fe13b0ca..c301f713e486 100644 --- a/drivers/net/3c509.c +++ b/drivers/net/3c509.c @@ -678,6 +678,8 @@ static int __init el3_mca_probe(struct device *device) { err = el3_common_init(dev); if (err) { + device->driver_data = NULL; + free_netdev(dev); return -ENOMEM; } @@ -737,6 +739,8 @@ static int __init el3_eisa_probe (struct device *device) err = el3_common_init(dev); if (err) { + eisa_set_drvdata (edev, NULL); + free_netdev(dev); return err; } diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c index eaa214a5a518..c363cecd6362 100644 --- a/drivers/net/acenic.c +++ b/drivers/net/acenic.c @@ -731,12 +731,6 @@ int __devinit acenic_probe (ACE_PROBE_ARG) break; } - if (register_netdev(dev)) { - printk(KERN_ERR "acenic: device registration failed\n"); - free_netdev(dev); - continue; - } - switch(pdev->vendor) { case PCI_VENDOR_ID_ALTEON: if (pdev->device == PCI_DEVICE_ID_FARALLON_PN9100T) { @@ -824,6 +818,13 @@ int __devinit acenic_probe (ACE_PROBE_ARG) continue; } + if (register_netdev(dev)) { + printk(KERN_ERR "acenic: device registration failed\n"); + ace_init_cleanup(dev); + free_netdev(dev); + continue; + } + if (ap->pci_using_dac) dev->features |= NETIF_F_HIGHDMA; @@ -874,6 +875,7 @@ static void __exit ace_module_cleanup(void) while (root_dev) { ap = root_dev->priv; next = ap->next; + unregister_netdev(root_dev); regs = ap->regs; @@ -1133,7 +1135,6 @@ static void ace_init_cleanup(struct net_device *dev) if (dev->irq) free_irq(dev->irq, dev); - unregister_netdev(dev); iounmap(ap->regs); } diff --git a/drivers/net/apne.c b/drivers/net/apne.c index 9070b1d154d1..968f29248f76 100644 --- a/drivers/net/apne.c +++ b/drivers/net/apne.c @@ -580,6 +580,8 @@ void cleanup_module(void) pcmcia_reset(); + release_region(IOBASE, 0x20); + free_netdev(apne_dev); } diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c index 579cf0d2ee5b..72dcdc04a9dc 100644 --- a/drivers/net/appletalk/cops.c +++ b/drivers/net/appletalk/cops.c @@ -262,7 +262,7 @@ struct net_device * __init cops_probe(int unit) out1: cleanup_card(dev); out: - kfree(dev); + free_netdev(dev); return ERR_PTR(err); } diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c index 8931196e04e0..2e9b6490d9f7 100644 --- a/drivers/net/arm/am79c961a.c +++ b/drivers/net/arm/am79c961a.c @@ -672,6 +672,10 @@ static int __init am79c961_init(void) dev->base_addr = 0x220; dev->irq = IRQ_EBSA110_ETHERNET; + ret = -ENODEV; + if (!request_region(dev->base_addr, 0x18, dev->name)) + goto nodev; + /* * Reset the device. */ @@ -682,14 +686,10 @@ static int __init am79c961_init(void) * Check the manufacturer part of the * ether address. */ - ret = -ENODEV; if (inb(dev->base_addr) != 0x08 || inb(dev->base_addr + 2) != 0x00 || inb(dev->base_addr + 4) != 0x2b) - goto nodev; - - if (!request_region(dev->base_addr, 0x18, dev->name)) - goto nodev; + goto release; am79c961_banner(); printk(KERN_INFO "%s: ether address ", dev->name); diff --git a/drivers/net/dgrs.c b/drivers/net/dgrs.c index 84652b61a8a4..83d4a7085ba0 100644 --- a/drivers/net/dgrs.c +++ b/drivers/net/dgrs.c @@ -121,11 +121,22 @@ typedef unsigned int bool; #include "dgrs_asstruct.h" #include "dgrs_bcomm.h" +#ifdef CONFIG_PCI static struct pci_device_id dgrs_pci_tbl[] = { { SE6_PCI_VENDOR_ID, SE6_PCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, }, { } /* Terminating entry */ }; MODULE_DEVICE_TABLE(pci, dgrs_pci_tbl); +#endif + +#ifdef CONFIG_EISA +static struct eisa_device_id dgrs_eisa_tbl[] = { + { "DBI0A01" }, + { } +}; +MODULE_DEVICE_TABLE(eisa, dgrs_eisa_tbl); +#endif + MODULE_LICENSE("GPL"); @@ -179,11 +190,6 @@ static __u32 dgrs_ipxnet = -1; static int dgrs_nicmode; /* - * Chain of device structures - */ -static struct net_device *dgrs_root_dev; - -/* * Private per-board data structure (dev->priv) */ typedef struct @@ -191,7 +197,6 @@ typedef struct /* * Stuff for generic ethercard I/F */ - struct net_device *next_dev; struct net_device_stats stats; /* @@ -1187,7 +1192,7 @@ dgrs_probe1(struct net_device *dev) priv->intrcnt = 0; for (i = jiffies + 2*HZ + HZ/2; time_after(i, jiffies); ) { - barrier(); /* gcc 2.95 needs this */ + cpu_relax(); if (priv->intrcnt >= 2) break; } @@ -1200,16 +1205,6 @@ dgrs_probe1(struct net_device *dev) } /* - * Register the /proc/ioports information... - */ - if (!request_region(dev->base_addr, 256, "RightSwitch")) { - printk(KERN_ERR "%s: io 0x%3lX, which is busy.\n", dev->name, - dev->base_addr); - rc = -EBUSY; - goto err_free_irq; - } - - /* * Entry points... */ dev->open = &dgrs_open; @@ -1242,22 +1237,23 @@ dgrs_initclone(struct net_device *dev) return (0); } -static int __init +static struct net_device * __init dgrs_found_device( int io, ulong mem, int irq, ulong plxreg, - ulong plxdma + ulong plxdma, + struct device *pdev ) { - DGRS_PRIV *priv; - struct net_device *dev, *aux; - int i, ret; + DGRS_PRIV *priv; + struct net_device *dev; + int i, ret = -ENOMEM; dev = alloc_etherdev(sizeof(DGRS_PRIV)); if (!dev) - return -ENOMEM; + goto err0; priv = (DGRS_PRIV *)dev->priv; @@ -1272,19 +1268,19 @@ dgrs_found_device( priv->chan = 1; priv->devtbl[0] = dev; - dev->init = dgrs_probe1; SET_MODULE_OWNER(dev); + SET_NETDEV_DEV(dev, pdev); + + ret = dgrs_probe1(dev); + if (ret) + goto err1; - if (register_netdev(dev) != 0) { - free_netdev(dev); - return -EIO; - } - - priv->next_dev = dgrs_root_dev; - dgrs_root_dev = dev; + ret = register_netdev(dev); + if (ret) + goto err2; if ( !dgrs_nicmode ) - return (0); /* Switch mode, we are done */ + return dev; /* Switch mode, we are done */ /* * Operating card as N separate NICs @@ -1302,8 +1298,7 @@ dgrs_found_device( if (!devN) goto fail; - /* Make it an exact copy of dev[0]... */ - *devN = *dev; + /* Don't copy the network device structure! */ /* copy the priv structure of dev[0] */ privN = (DGRS_PRIV *)devN->priv; @@ -1316,122 +1311,211 @@ dgrs_found_device( devN->irq = 0; /* ... and base MAC address off address of 1st port */ devN->dev_addr[5] += i; - /* ... choose a new name */ - strncpy(devN->name, "eth%d", IFNAMSIZ); - devN->init = dgrs_initclone; + + ret = dgrs_initclone(devN); + if (ret) + goto fail; + SET_MODULE_OWNER(devN); + SET_NETDEV_DEV(dev, pdev); - ret = -EIO; - if (register_netdev(devN)) { + ret = register_netdev(devN); + if (ret) { free_netdev(devN); goto fail; } privN->chan = i+1; priv->devtbl[i] = devN; - privN->next_dev = dgrs_root_dev; - dgrs_root_dev = devN; } - return 0; -fail: aux = priv->next_dev; - while (dgrs_root_dev != aux) { - struct net_device *d = dgrs_root_dev; - - dgrs_root_dev = ((DGRS_PRIV *)d->priv)->next_dev; + return dev; + + fail: + while (i >= 0) { + struct net_device *d = priv->devtbl[i--]; unregister_netdev(d); free_netdev(d); } - return ret; + + err2: + free_irq(dev->irq, dev); + err1: + free_netdev(dev); + err0: + return ERR_PTR(ret); } -/* - * Scan for all boards - */ -static int is2iv[8] __initdata = { 0, 3, 5, 7, 10, 11, 12, 15 }; +static void __devexit dgrs_remove(struct net_device *dev) +{ + DGRS_PRIV *priv = dev->priv; + int i; + + unregister_netdev(dev); + + for (i = 1; i < priv->nports; ++i) { + struct net_device *d = priv->devtbl[i]; + if (d) { + unregister_netdev(d); + free_netdev(d); + } + } + + proc_reset(priv->devtbl[0], 1); + + if (priv->vmem) + iounmap(priv->vmem); + if (priv->vplxdma) + iounmap((uchar *) priv->vplxdma); + + if (dev->irq) + free_irq(dev->irq, dev); -static int __init dgrs_scan(void) + for (i = 1; i < priv->nports; ++i) { + if (priv->devtbl[i]) + unregister_netdev(priv->devtbl[i]); + } +} + +#ifdef CONFIG_PCI +static int __init dgrs_pci_probe(struct pci_dev *pdev, + const struct pci_device_id *ent) { - int cards_found = 0; + struct net_device *dev; + int err; uint io; uint mem; uint irq; uint plxreg; uint plxdma; - struct pci_dev *pdev = NULL; /* - * First, check for PCI boards + * Get and check the bus-master and latency values. + * Some PCI BIOSes fail to set the master-enable bit, + * and the latency timer must be set to the maximum + * value to avoid data corruption that occurs when the + * timer expires during a transfer. Yes, it's a bug. */ - while ((pdev = pci_find_device(SE6_PCI_VENDOR_ID, SE6_PCI_DEVICE_ID, pdev)) != NULL) - { - /* - * Get and check the bus-master and latency values. - * Some PCI BIOSes fail to set the master-enable bit, - * and the latency timer must be set to the maximum - * value to avoid data corruption that occurs when the - * timer expires during a transfer. Yes, it's a bug. - */ - if (pci_enable_device(pdev)) - continue; - pci_set_master(pdev); + err = pci_enable_device(pdev); + if (err) + return err; + err = pci_request_regions(pdev, "RightSwitch"); + if (err) + return err; + + pci_set_master(pdev); + + plxreg = pci_resource_start (pdev, 0); + io = pci_resource_start (pdev, 1); + mem = pci_resource_start (pdev, 2); + pci_read_config_dword(pdev, 0x30, &plxdma); + irq = pdev->irq; + plxdma &= ~15; - plxreg = pci_resource_start (pdev, 0); - io = pci_resource_start (pdev, 1); - mem = pci_resource_start (pdev, 2); - pci_read_config_dword(pdev, 0x30, &plxdma); - irq = pdev->irq; - plxdma &= ~15; + /* + * On some BIOSES, the PLX "expansion rom" (used for DMA) + * address comes up as "0". This is probably because + * the BIOS doesn't see a valid 55 AA ROM signature at + * the "ROM" start and zeroes the address. To get + * around this problem the SE-6 is configured to ask + * for 4 MB of space for the dual port memory. We then + * must set its range back to 2 MB, and use the upper + * half for DMA register access + */ + OUTL(io + PLX_SPACE0_RANGE, 0xFFE00000L); + if (plxdma == 0) + plxdma = mem + (2048L * 1024L); + pci_write_config_dword(pdev, 0x30, plxdma + 1); + pci_read_config_dword(pdev, 0x30, &plxdma); + plxdma &= ~15; + + dev = dgrs_found_device(io, mem, irq, plxreg, plxdma, &pdev->dev); + if (IS_ERR(dev)) { + pci_release_regions(pdev); + return PTR_ERR(dev); + } - /* - * On some BIOSES, the PLX "expansion rom" (used for DMA) - * address comes up as "0". This is probably because - * the BIOS doesn't see a valid 55 AA ROM signature at - * the "ROM" start and zeroes the address. To get - * around this problem the SE-6 is configured to ask - * for 4 MB of space for the dual port memory. We then - * must set its range back to 2 MB, and use the upper - * half for DMA register access - */ - OUTL(io + PLX_SPACE0_RANGE, 0xFFE00000L); - if (plxdma == 0) - plxdma = mem + (2048L * 1024L); - pci_write_config_dword(pdev, 0x30, plxdma + 1); - pci_read_config_dword(pdev, 0x30, &plxdma); - plxdma &= ~15; + pci_set_drvdata(pdev, dev); + return 0; +} - dgrs_found_device(io, mem, irq, plxreg, plxdma); +static void __devexit dgrs_pci_remove(struct pci_dev *pdev) +{ + struct net_device *dev = pci_get_drvdata(pdev); - cards_found++; - } + dgrs_remove(dev); + pci_release_regions(pdev); + free_netdev(dev); +} - /* - * Second, check for EISA boards - */ - if (EISA_bus) - { - for (io = 0x1000; io < 0x9000; io += 0x1000) - { - if (inb(io+ES4H_MANUFmsb) != 0x10 - || inb(io+ES4H_MANUFlsb) != 0x49 - || inb(io+ES4H_PRODUCT) != ES4H_PRODUCT_CODE) - continue; +static struct pci_driver dgrs_pci_driver = { + .name = "dgrs", + .id_table = dgrs_pci_tbl, + .probe = dgrs_pci_probe, + .remove = __devexit_p(dgrs_pci_remove), +}; +#endif - if ( ! (inb(io+ES4H_EC) & ES4H_EC_ENABLE) ) - continue; /* Not EISA configured */ - mem = (inb(io+ES4H_AS_31_24) << 24) - + (inb(io+ES4H_AS_23_16) << 16); +#ifdef CONFIG_EISA +static int is2iv[8] __initdata = { 0, 3, 5, 7, 10, 11, 12, 15 }; - irq = is2iv[ inb(io+ES4H_IS) & ES4H_IS_INTMASK ]; +static int __init dgrs_eisa_probe (struct device *gendev) +{ + struct net_device *dev; + struct eisa_device *edev = to_eisa_device(gendev); + uint io = edev->base_addr; + uint mem; + uint irq; + int rc = -ENODEV; /* Not EISA configured */ - dgrs_found_device(io, mem, irq, 0L, 0L); + if (!request_region(io, 256, "RightSwitch")) { + printk(KERN_ERR "%s: io 0x%3lX, which is busy.\n", dev->name, + dev->base_addr); + return -EBUSY; + } - ++cards_found; - } + if ( ! (inb(io+ES4H_EC) & ES4H_EC_ENABLE) ) + goto err_out; + + mem = (inb(io+ES4H_AS_31_24) << 24) + + (inb(io+ES4H_AS_23_16) << 16); + + irq = is2iv[ inb(io+ES4H_IS) & ES4H_IS_INTMASK ]; + + dev = dgrs_found_device(io, mem, irq, 0L, 0L, gendev); + if (IS_ERR(dev)) { + rc = PTR_ERR(dev); + goto err_out; } - return cards_found; + gendev->driver_data = dev; + return 0; + err_out: + release_region(io, 256); + return rc; } +static int __devexit dgrs_eisa_remove(struct device *gendev) +{ + struct net_device *dev = gendev->driver_data; + + dgrs_remove(dev); + + release_region(dev->base_addr, 256); + + free_netdev(dev); + return 0; +} + + +static struct eisa_driver dgrs_eisa_driver = { + .id_table = dgrs_eisa_tbl, + .driver = { + .name = "dgrs", + .probe = dgrs_eisa_probe, + .remove = __devexit_p(dgrs_eisa_remove), + } +}; +#endif /* * Variables that can be overriden from module command line @@ -1459,8 +1543,8 @@ MODULE_PARM_DESC(nicmode, "Digi RightSwitch operating mode (1: switch, 2: multi- static int __init dgrs_init_module (void) { - int cards_found; int i; + int eisacount = 0, pcicount = 0; /* * Command line variable overrides @@ -1501,38 +1585,27 @@ static int __init dgrs_init_module (void) /* * Find and configure all the cards */ - dgrs_root_dev = NULL; - cards_found = dgrs_scan(); - - return cards_found ? 0 : -ENODEV; +#ifdef CONFIG_EISA + eisacount = eisa_driver_register(&dgrs_eisa_driver); + if (eisacount < 0) + return eisacount; +#endif +#ifdef CONFIG_PCI + pcicount = pci_register_driver(&dgrs_pci_driver); + if (pcicount < 0) + return pcicount; +#endif + return (eisacount + pcicount) == 0 ? -ENODEV : 0; } static void __exit dgrs_cleanup_module (void) { - while (dgrs_root_dev) - { - struct net_device *next_dev; - DGRS_PRIV *priv; - - priv = (DGRS_PRIV *) dgrs_root_dev->priv; - next_dev = priv->next_dev; - unregister_netdev(dgrs_root_dev); - - proc_reset(priv->devtbl[0], 1); - - if (priv->vmem) - iounmap(priv->vmem); - if (priv->vplxdma) - iounmap((uchar *) priv->vplxdma); - - release_region(dgrs_root_dev->base_addr, 256); - - if (dgrs_root_dev->irq) - free_irq(dgrs_root_dev->irq, dgrs_root_dev); - - free_netdev(dgrs_root_dev); - dgrs_root_dev = next_dev; - } +#ifdef CONFIG_EISA + eisa_driver_unregister (&dgrs_eisa_driver); +#endif +#ifdef CONFIG_PCI + pci_unregister_driver (&dgrs_pci_driver); +#endif } module_init(dgrs_init_module); diff --git a/drivers/net/fc/iph5526.c b/drivers/net/fc/iph5526.c index 11a346c69733..c920132514f9 100644 --- a/drivers/net/fc/iph5526.c +++ b/drivers/net/fc/iph5526.c @@ -4501,7 +4501,7 @@ static int __init iph5526_init(void) iph5526_probe_pci(dev); err = register_netdev(dev); if (err < 0) { - kfree(dev); + free_netdev(dev); printk("iph5526.c: init_fcdev failed for card #%d\n", i+1); break; } diff --git a/drivers/net/fec.c b/drivers/net/fec.c index 47ce93a052f2..95fef341cea4 100644 --- a/drivers/net/fec.c +++ b/drivers/net/fec.c @@ -1638,9 +1638,12 @@ fec_set_mac_address(struct net_device *dev) /* Initialize the FEC Ethernet on 860T (or ColdFire 5272). */ + /* + * XXX: We need to clean up on failure exits here. + */ int __init fec_enet_init(struct net_device *dev) { - struct fec_enet_private *fep; + struct fec_enet_private *fep = dev->priv; unsigned long mem_addr; volatile cbd_t *bdp; cbd_t *cbd_base; @@ -1651,13 +1654,6 @@ int __init fec_enet_init(struct net_device *dev) if (found) return(-ENXIO); - /* Allocate some private information. - */ - fep = (struct fec_enet_private *)kmalloc(sizeof(*fep), GFP_KERNEL); - if (!fep) - return -ENOMEM; - memset(fep, 0, sizeof(*fep)); - /* Create an Ethernet device instance. */ fecp = fec_hwp; @@ -1694,6 +1690,7 @@ int __init fec_enet_init(struct net_device *dev) } mem_addr = __get_free_page(GFP_KERNEL); cbd_base = (cbd_t *)mem_addr; + /* XXX: missing check for allocation failure */ fec_uncache(mem_addr); @@ -1715,6 +1712,7 @@ int __init fec_enet_init(struct net_device *dev) /* Allocate a page. */ mem_addr = __get_free_page(GFP_KERNEL); + /* XXX: missing check for allocation failure */ fec_uncache(mem_addr); @@ -1761,9 +1759,6 @@ int __init fec_enet_init(struct net_device *dev) fec_request_intrs(dev, fecp); dev->base_addr = (unsigned long)fecp; - dev->priv = fep; - - ether_setup(dev); /* The FEC Ethernet specific entries in the device structure. */ dev->open = fec_enet_open; @@ -1949,14 +1944,28 @@ fec_stop(struct net_device *dev) fecp->fec_mii_speed = fep->phy_speed; } -static struct net_device fec_dev = { - .init = fec_enet_init, -}; +static struct net_device *fec_dev; static int __init fec_enet_module_init(void) { - if (register_netdev(&fec_dev) != 0) + struct net_device *dev; + int err; + + dev = alloc_etherdev(sizeof(struct fec_enet_private)); + if (!dev) + return -ENOMEM; + err = fec_enet_init(dev); + if (err) { + free_netdev(dev); + return err; + } + + if (register_netdev(dev) != 0) { + /* XXX: missing cleanup here */ + free_netdev(dev); return -EIO; + } + fec_dev = dev; return(0); } diff --git a/drivers/net/isa-skeleton.c b/drivers/net/isa-skeleton.c index 6bc03583c5d7..8a78635619a1 100644 --- a/drivers/net/isa-skeleton.c +++ b/drivers/net/isa-skeleton.c @@ -104,8 +104,6 @@ struct net_local { /* Index to functions, as function prototypes. */ -extern int netcard_probe(struct net_device *dev); - static int netcard_probe1(struct net_device *dev, int ioaddr); static int net_open(struct net_device *dev); static int net_send_packet(struct sk_buff *skb, struct net_device *dev); @@ -129,11 +127,11 @@ static void chipset_init(struct net_device *dev, int startp); * If dev->base_addr == 2, allocate space for the device and return success * (detachable devices only). */ -int __init -netcard_probe(struct net_device *dev) +static int __init do_netcard_probe(struct net_device *dev) { int i; int base_addr = dev->base_addr; + int irq = dev->irq; SET_MODULE_OWNER(dev); @@ -144,14 +142,49 @@ netcard_probe(struct net_device *dev) for (i = 0; netcard_portlist[i]; i++) { int ioaddr = netcard_portlist[i]; - if (check_region(ioaddr, NETCARD_IO_EXTENT)) - continue; if (netcard_probe1(dev, ioaddr) == 0) return 0; + dev->irq = irq; } return -ENODEV; } + +static void cleanup_card(struct net_device *dev) +{ +#ifdef jumpered_dma + free_dma(dev->dma); +#endif +#ifdef jumpered_interrupts + free_irq(dev->irq, dev); +#endif + release_region(dev->base_addr, NETCARD_IO_EXTENT); +} + +struct net_device * __init netcard_probe(int unit) +{ + struct net_device *dev = alloc_etherdev(sizeof(struct net_local)); + int err; + + if (!dev) + return ERR_PTR(-ENOMEM); + + sprintf(dev->name, "eth%d", unit); + netdev_boot_setup_check(dev); + + err = do_netcard_probe(dev); + if (err) + goto out; + err = register_netdev(dev); + if (err) + goto out1; + return dev; +out1: + cleanup_card(dev); +out: + free_netdev(dev); + return ERR_PTR(err); +} /* * This is the real probe routine. Linux has a history of friendly device @@ -163,6 +196,11 @@ static int __init netcard_probe1(struct net_device *dev, int ioaddr) struct net_local *np; static unsigned version_printed; int i; + int err = -ENODEV; + + /* Grab the region so that no one else tries to probe our ioports. */ + if (!request_region(ioaddr, NETCARD_IO_EXTENT, cardname)) + return -EBUSY; /* * For ethernet adaptors the first three octets of the station address @@ -171,9 +209,8 @@ static int __init netcard_probe1(struct net_device *dev, int ioaddr) */ if (inb(ioaddr + 0) != SA_ADDR0 || inb(ioaddr + 1) != SA_ADDR1 - || inb(ioaddr + 2) != SA_ADDR2) { - return -ENODEV; - } + || inb(ioaddr + 2) != SA_ADDR2) + goto out; if (net_debug && version_printed++ == 0) printk(KERN_DEBUG "%s", version); @@ -187,6 +224,7 @@ static int __init netcard_probe1(struct net_device *dev, int ioaddr) for (i = 0; i < 6; i++) printk(" %2.2x", dev->dev_addr[i] = inb(ioaddr + i)); + err = -EAGAIN; #ifdef jumpered_interrupts /* * If this board has jumpered interrupts, allocate the interrupt @@ -217,7 +255,7 @@ static int __init netcard_probe1(struct net_device *dev, int ioaddr) if (irqval) { printk("%s: unable to get IRQ %d (irqval=%d).\n", dev->name, dev->irq, irqval); - return -EAGAIN; + goto out; } } #endif /* jumpered interrupt */ @@ -229,7 +267,7 @@ static int __init netcard_probe1(struct net_device *dev, int ioaddr) if (dev->dma == 0) { if (request_dma(dev->dma, cardname)) { printk("DMA %d allocation failed.\n", dev->dma); - return -EAGAIN; + goto out1; } else printk(", assigned DMA %d.\n", dev->dma); } else { @@ -256,30 +294,18 @@ static int __init netcard_probe1(struct net_device *dev, int ioaddr) } if (i <= 0) { printk("DMA probe failed.\n"); - return -EAGAIN; + goto out1; } if (request_dma(dev->dma, cardname)) { printk("probed DMA %d allocation failed.\n", dev->dma); - return -EAGAIN; + goto out1; } } #endif /* jumpered DMA */ - /* Initialize the device structure. */ - if (dev->priv == NULL) { - dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL); - if (dev->priv == NULL) - return -ENOMEM; - } - - memset(dev->priv, 0, sizeof(struct net_local)); - np = (struct net_local *)dev->priv; spin_lock_init(&np->lock); - /* Grab the region so that no one else tries to probe our ioports. */ - request_region(ioaddr, NETCARD_IO_EXTENT, cardname); - dev->open = net_open; dev->stop = net_close; dev->hard_start_xmit = net_send_packet; @@ -288,11 +314,14 @@ static int __init netcard_probe1(struct net_device *dev, int ioaddr) dev->tx_timeout = &net_tx_timeout; dev->watchdog_timeo = MY_TX_TIMEOUT; - - /* Fill in the fields of the device structure with ethernet values. */ - ether_setup(dev); - return 0; +out1: +#ifdef jumpered_interrupts + free_irq(dev->irq, dev); +#endif +out: + release_region(base_addr, NETCARD_IO_EXTENT); + return err; } static void net_tx_timeout(struct net_device *dev) @@ -635,7 +664,7 @@ set_multicast_list(struct net_device *dev) #ifdef MODULE -static struct net_device this_device; +static struct net_device *this_device; static int io = 0x300; static int irq; static int dma; @@ -644,42 +673,38 @@ MODULE_LICENSE("GPL"); int init_module(void) { + struct net_device *dev; int result; if (io == 0) printk(KERN_WARNING "%s: You shouldn't use auto-probing with insmod!\n", cardname); + dev = alloc_etherdev(sizeof(struct net_local)); + if (!dev) + return -ENOMEM; /* Copy the parameters from insmod into the device structure. */ - this_device.base_addr = io; - this_device.irq = irq; - this_device.dma = dma; - this_device.mem_start = mem; - this_device.init = netcard_probe; - - if ((result = register_netdev(&this_device)) != 0) - return result; - - return 0; + dev->base_addr = io; + dev->irq = irq; + dev->dma = dma; + dev->mem_start = mem; + if (do_netcard_probe(dev) == 0) { + if (register_netdev(dev) == 0) + this_device = dev; + return 0; + } + cleanup_card(dev); + } + free_netdev(dev); + return -ENXIO; } void cleanup_module(void) { - unregister_netdev(&this_device); - /* - * If we don't do this, we can't re-insmod it later. - * Release irq/dma here, when you have jumpered versions and - * allocate them in net_probe1(). - */ - /* - free_irq(this_device.irq, dev); - free_dma(this_device.dma); - */ - release_region(this_device.base_addr, NETCARD_IO_EXTENT); - - if (this_device.priv) - kfree(this_device.priv); + unregister_netdev(this_device); + cleanup_card(this_device); + free_netdev(this_device); } #endif /* MODULE */ diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c index 011eaf26e9f6..832a80ba483c 100644 --- a/drivers/net/pppoe.c +++ b/drivers/net/pppoe.c @@ -67,7 +67,6 @@ #include <linux/ppp_channel.h> #include <linux/ppp_defs.h> #include <linux/if_ppp.h> -#include <linux/if_pppvar.h> #include <linux/notifier.h> #include <linux/file.h> #include <linux/proc_fs.h> diff --git a/drivers/net/saa9730.c b/drivers/net/saa9730.c index c7139e50e8af..ffae7c72f65e 100644 --- a/drivers/net/saa9730.c +++ b/drivers/net/saa9730.c @@ -1028,6 +1028,9 @@ static int lan_saa9730_init(struct net_device *dev, int ioaddr, int irq) * Make certain the data structures used by the controller are aligned * and DMAble. */ + /* + * XXX: that is obviously broken - kfree() won't be happy with us. + */ lp = (struct lan_saa9730_private *) (((unsigned long) kmalloc(sizeof(*lp) + 7, GFP_DMA | GFP_KERNEL) @@ -1095,7 +1098,6 @@ static int lan_saa9730_init(struct net_device *dev, int ioaddr, int irq) out: if (dev->priv) kfree(dev->priv); - free_netdev(dev); return ret; } diff --git a/drivers/net/shaper.c b/drivers/net/shaper.c index e7ae3e6bb30f..9352fc63c262 100644 --- a/drivers/net/shaper.c +++ b/drivers/net/shaper.c @@ -642,7 +642,6 @@ static void __init shaper_setup(struct net_device *dev) dev->open = shaper_open; dev->stop = shaper_close; - dev->destructor = free_netdev; dev->hard_start_xmit = shaper_start_xmit; dev->get_stats = shaper_get_stats; dev->set_multicast_list = NULL; diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c index 943850c411e9..3692f3e24efe 100644 --- a/drivers/net/tokenring/3c359.c +++ b/drivers/net/tokenring/3c359.c @@ -1129,7 +1129,7 @@ static irqreturn_t xl_interrupt(int irq, void *dev_id, struct pt_regs *regs) xl_freemem(dev) ; free_irq(dev->irq,dev); unregister_netdev(dev) ; - kfree(dev) ; + free_netdev(dev) ; xl_reset(dev) ; writel(ACK_INTERRUPT | LATCH_ACK, xl_mmio + MMIO_COMMAND) ; spin_unlock(&xl_priv->xl_lock) ; diff --git a/drivers/net/wan/dlci.c b/drivers/net/wan/dlci.c index 6d3d2d461a75..82798fd0e94d 100644 --- a/drivers/net/wan/dlci.c +++ b/drivers/net/wan/dlci.c @@ -414,7 +414,7 @@ static int dlci_add(struct dlci_add *dlci) err2: rtnl_unlock(); - kfree(master); + free_netdev(master); err1: dev_put(slave); return(err); diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c index 6f2dfbdc986c..e9c995ea1cdc 100644 --- a/drivers/net/wan/hdlc_fr.c +++ b/drivers/net/wan/hdlc_fr.c @@ -1095,7 +1095,7 @@ static int fr_del_pvc(hdlc_device *hdlc, unsigned int dlci, int type) if (dev->flags & IFF_UP) return -EBUSY; /* PVC in use */ - unregister_netdevice(dev); /* the destructor will kfree(dev) */ + unregister_netdevice(dev); /* the destructor will free_netdev(dev) */ *get_dev_p(pvc, type) = NULL; if (!pvc_is_used(pvc)) { @@ -1119,7 +1119,8 @@ static void fr_destroy(hdlc_device *hdlc) while (pvc) { pvc_device *next = pvc->next; - if (pvc->main) /* the destructor will kfree(main + ether) */ + /* destructors will free_netdev() main and ether */ + if (pvc->main) unregister_netdevice(pvc->main); if (pvc->ether) diff --git a/drivers/net/wan/hostess_sv11.c b/drivers/net/wan/hostess_sv11.c index 24a87299c447..be8d583b3b7c 100644 --- a/drivers/net/wan/hostess_sv11.c +++ b/drivers/net/wan/hostess_sv11.c @@ -341,8 +341,9 @@ static struct sv11_device *sv11_init(int iobase, int irq) { printk(KERN_ERR "%s: unable to register device.\n", d->name); - goto fail; - } + sppp_detach(d); + goto dmafail2; + } z8530_describe(dev, "I/O", iobase); dev->active=1; diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c index e9301a89a0f8..eb176da78cfb 100644 --- a/drivers/net/wan/lapbether.c +++ b/drivers/net/wan/lapbether.c @@ -375,6 +375,7 @@ out: return rc; fail: dev_put(dev); + free_netdev(ndev); kfree(lapbeth); goto out; } diff --git a/drivers/net/wan/sdla.c b/drivers/net/wan/sdla.c index 80c9d0627072..3a8432062154 100644 --- a/drivers/net/wan/sdla.c +++ b/drivers/net/wan/sdla.c @@ -1339,6 +1339,8 @@ int sdla_set_config(struct net_device *dev, struct ifmap *map) struct frad_local *flp; int i; char byte; + unsigned base; + int err = -EINVAL; flp = dev->priv; @@ -1352,108 +1354,90 @@ int sdla_set_config(struct net_device *dev, struct ifmap *map) if (i == sizeof(valid_port) / sizeof(int)) return(-EINVAL); - dev->base_addr = map->base_addr; - if (!request_region(dev->base_addr, SDLA_IO_EXTENTS, dev->name)){ + if (!request_region(map->base_addr, SDLA_IO_EXTENTS, dev->name)){ printk(KERN_WARNING "SDLA: io-port 0x%04lx in use \n", dev->base_addr); return(-EINVAL); } + base = map->base_addr; + /* test for card types, S502A, S502E, S507, S508 */ /* these tests shut down the card completely, so clear the state */ flp->type = SDLA_UNKNOWN; flp->state = 0; for(i=1;i<SDLA_IO_EXTENTS;i++) - if (inb(dev->base_addr + i) != 0xFF) + if (inb(base + i) != 0xFF) break; - if (i == SDLA_IO_EXTENTS) - { - outb(SDLA_HALT, dev->base_addr + SDLA_REG_Z80_CONTROL); - if ((inb(dev->base_addr + SDLA_S502_STS) & 0x0F) == 0x08) - { - outb(SDLA_S502E_INTACK, dev->base_addr + SDLA_REG_CONTROL); - if ((inb(dev->base_addr + SDLA_S502_STS) & 0x0F) == 0x0C) - { - outb(SDLA_HALT, dev->base_addr + SDLA_REG_CONTROL); + if (i == SDLA_IO_EXTENTS) { + outb(SDLA_HALT, base + SDLA_REG_Z80_CONTROL); + if ((inb(base + SDLA_S502_STS) & 0x0F) == 0x08) { + outb(SDLA_S502E_INTACK, base + SDLA_REG_CONTROL); + if ((inb(base + SDLA_S502_STS) & 0x0F) == 0x0C) { + outb(SDLA_HALT, base + SDLA_REG_CONTROL); flp->type = SDLA_S502E; + goto got_type; } } } - if (flp->type == SDLA_UNKNOWN) - { - for(byte=inb(dev->base_addr),i=0;i<SDLA_IO_EXTENTS;i++) - if (inb(dev->base_addr + i) != byte) - break; + for(byte=inb(base),i=0;i<SDLA_IO_EXTENTS;i++) + if (inb(base + i) != byte) + break; - if (i == SDLA_IO_EXTENTS) - { - outb(SDLA_HALT, dev->base_addr + SDLA_REG_CONTROL); - if ((inb(dev->base_addr + SDLA_S502_STS) & 0x7E) == 0x30) - { - outb(SDLA_S507_ENABLE, dev->base_addr + SDLA_REG_CONTROL); - if ((inb(dev->base_addr + SDLA_S502_STS) & 0x7E) == 0x32) - { - outb(SDLA_HALT, dev->base_addr + SDLA_REG_CONTROL); - flp->type = SDLA_S507; - } + if (i == SDLA_IO_EXTENTS) { + outb(SDLA_HALT, base + SDLA_REG_CONTROL); + if ((inb(base + SDLA_S502_STS) & 0x7E) == 0x30) { + outb(SDLA_S507_ENABLE, base + SDLA_REG_CONTROL); + if ((inb(base + SDLA_S502_STS) & 0x7E) == 0x32) { + outb(SDLA_HALT, base + SDLA_REG_CONTROL); + flp->type = SDLA_S507; + goto got_type; } } } - if (flp->type == SDLA_UNKNOWN) - { - outb(SDLA_HALT, dev->base_addr + SDLA_REG_CONTROL); - if ((inb(dev->base_addr + SDLA_S508_STS) & 0x3F) == 0x00) - { - outb(SDLA_S508_INTEN, dev->base_addr + SDLA_REG_CONTROL); - if ((inb(dev->base_addr + SDLA_S508_STS) & 0x3F) == 0x10) - { - outb(SDLA_HALT, dev->base_addr + SDLA_REG_CONTROL); - flp->type = SDLA_S508; - } + outb(SDLA_HALT, base + SDLA_REG_CONTROL); + if ((inb(base + SDLA_S508_STS) & 0x3F) == 0x00) { + outb(SDLA_S508_INTEN, base + SDLA_REG_CONTROL); + if ((inb(base + SDLA_S508_STS) & 0x3F) == 0x10) { + outb(SDLA_HALT, base + SDLA_REG_CONTROL); + flp->type = SDLA_S508; + goto got_type; } } - if (flp->type == SDLA_UNKNOWN) - { - outb(SDLA_S502A_HALT, dev->base_addr + SDLA_REG_CONTROL); - if (inb(dev->base_addr + SDLA_S502_STS) == 0x40) - { - outb(SDLA_S502A_START, dev->base_addr + SDLA_REG_CONTROL); - if (inb(dev->base_addr + SDLA_S502_STS) == 0x40) - { - outb(SDLA_S502A_INTEN, dev->base_addr + SDLA_REG_CONTROL); - if (inb(dev->base_addr + SDLA_S502_STS) == 0x44) - { - outb(SDLA_S502A_START, dev->base_addr + SDLA_REG_CONTROL); - flp->type = SDLA_S502A; - } + outb(SDLA_S502A_HALT, base + SDLA_REG_CONTROL); + if (inb(base + SDLA_S502_STS) == 0x40) { + outb(SDLA_S502A_START, base + SDLA_REG_CONTROL); + if (inb(base + SDLA_S502_STS) == 0x40) { + outb(SDLA_S502A_INTEN, base + SDLA_REG_CONTROL); + if (inb(base + SDLA_S502_STS) == 0x44) { + outb(SDLA_S502A_START, base + SDLA_REG_CONTROL); + flp->type = SDLA_S502A; + goto got_type; } } } - if (flp->type == SDLA_UNKNOWN) - { - printk(KERN_NOTICE "%s: Unknown card type\n", dev->name); - return(-ENODEV); - } + printk(KERN_NOTICE "%s: Unknown card type\n", dev->name); + err = -ENODEV; + goto fail; - switch(dev->base_addr) - { +got_type: + switch(base) { case 0x270: case 0x280: case 0x380: case 0x390: - if ((flp->type != SDLA_S508) && (flp->type != SDLA_S507)) - return(-EINVAL); + if (flp->type != SDLA_S508 && flp->type != SDLA_S507) + goto fail; } - switch (map->irq) - { + switch (map->irq) { case 2: if (flp->type != SDLA_S502E) - return(-EINVAL); + goto fail; break; case 10: @@ -1461,28 +1445,26 @@ int sdla_set_config(struct net_device *dev, struct ifmap *map) case 12: case 15: case 4: - if ((flp->type != SDLA_S508) && (flp->type != SDLA_S507)) - return(-EINVAL); - + if (flp->type != SDLA_S508 && flp->type != SDLA_S507) + goto fail; + break; case 3: case 5: case 7: if (flp->type == SDLA_S502A) - return(-EINVAL); + goto fail; break; default: - return(-EINVAL); + goto fail; } - dev->irq = map->irq; + err = -EAGAIN; if (request_irq(dev->irq, &sdla_isr, 0, dev->name, dev)) - return(-EAGAIN); + goto fail; - if (flp->type == SDLA_S507) - { - switch(dev->irq) - { + if (flp->type == SDLA_S507) { + switch(dev->irq) { case 3: flp->state = SDLA_S507_IRQ3; break; @@ -1514,35 +1496,25 @@ int sdla_set_config(struct net_device *dev, struct ifmap *map) if (valid_mem[i] == map->mem_start) break; + err = -EINVAL; if (i == sizeof(valid_mem) / sizeof(int)) - /* - * FIXME: - * BUG BUG BUG: MUST RELEASE THE IRQ WE ALLOCATED IN - * ALL THESE CASES - * - */ - return(-EINVAL); + goto fail2; - if ((flp->type == SDLA_S502A) && (((map->mem_start & 0xF000) >> 12) == 0x0E)) - return(-EINVAL); + if (flp->type == SDLA_S502A && (map->mem_start & 0xF000) >> 12 == 0x0E) + goto fail2; - if ((flp->type != SDLA_S507) && ((map->mem_start >> 16) == 0x0B)) - return(-EINVAL); + if (flp->type != SDLA_S507 && map->mem_start >> 16 == 0x0B) + goto fail2; - if ((flp->type == SDLA_S507) && ((map->mem_start >> 16) == 0x0D)) - return(-EINVAL); - - dev->mem_start = map->mem_start; - dev->mem_end = dev->mem_start + 0x2000; + if (flp->type == SDLA_S507 && map->mem_start >> 16 == 0x0D) + goto fail2; byte = flp->type != SDLA_S508 ? SDLA_8K_WINDOW : 0; byte |= (map->mem_start & 0xF000) >> (12 + (flp->type == SDLA_S508 ? 1 : 0)); - switch(flp->type) - { + switch(flp->type) { case SDLA_S502A: case SDLA_S502E: - switch (map->mem_start >> 16) - { + switch (map->mem_start >> 16) { case 0x0A: byte |= SDLA_S502_SEG_A; break; @@ -1558,8 +1530,7 @@ int sdla_set_config(struct net_device *dev, struct ifmap *map) } break; case SDLA_S507: - switch (map->mem_start >> 16) - { + switch (map->mem_start >> 16) { case 0x0A: byte |= SDLA_S507_SEG_A; break; @@ -1575,8 +1546,7 @@ int sdla_set_config(struct net_device *dev, struct ifmap *map) } break; case SDLA_S508: - switch (map->mem_start >> 16) - { + switch (map->mem_start >> 16) { case 0x0A: byte |= SDLA_S508_SEG_A; break; @@ -1594,7 +1564,7 @@ int sdla_set_config(struct net_device *dev, struct ifmap *map) } /* set the memory bits, and enable access */ - outb(byte, dev->base_addr + SDLA_REG_PC_WINDOW); + outb(byte, base + SDLA_REG_PC_WINDOW); switch(flp->type) { @@ -1608,10 +1578,20 @@ int sdla_set_config(struct net_device *dev, struct ifmap *map) flp->state = SDLA_MEMEN; break; } - outb(flp->state, dev->base_addr + SDLA_REG_CONTROL); + outb(flp->state, base + SDLA_REG_CONTROL); + dev->irq = map->irq; + dev->base_addr = base; + dev->mem_start = map->mem_start; + dev->mem_end = dev->mem_start + 0x2000; flp->initialized = 1; - return(0); + return 0; + +fail2: + free_irq(map->irq, dev); +fail: + release_region(base, SDLA_IO_EXTENTS); + return err; } static struct net_device_stats *sdla_stats(struct net_device *dev) @@ -1676,13 +1656,13 @@ static int __init init_sdla(void) static void __exit exit_sdla(void) { - struct frad_local *flp; + struct frad_local *flp = sdla->priv; unregister_netdev(sdla); - if (sdla->irq) + if (flp->initialized) { free_irq(sdla->irq, sdla); - - flp = sdla->priv; + release_region(sdla->base_addr, SDLA_IO_EXTENTS); + } del_timer_sync(&flp->timer); free_netdev(sdla); } diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index e3e72656073c..c2c9a708c9cd 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c @@ -2104,10 +2104,8 @@ int wll_header_parse(struct sk_buff *skb, unsigned char *haddr) return ETH_ALEN; } -static void wifi_setup(struct net_device *dev, struct net_device *ethdev) +static void wifi_setup(struct net_device *dev) { - struct airo_info *ai = ethdev->priv; - dev->priv = ai; dev->hard_header = 0; dev->rebuild_header = 0; dev->hard_header_cache = 0; @@ -2127,14 +2125,11 @@ static void wifi_setup(struct net_device *dev, struct net_device *ethdev) dev->change_mtu = &airo_change_mtu; dev->open = &airo_open; dev->stop = &airo_close; - dev->irq = ethdev->irq; - dev->base_addr = ethdev->base_addr; dev->type = ARPHRD_IEEE80211; dev->hard_header_len = ETH_HLEN; dev->mtu = 2312; dev->addr_len = ETH_ALEN; - memcpy(dev->dev_addr, ethdev->dev_addr, dev->addr_len); dev->tx_queue_len = 100; memset(dev->broadcast,0xFF, ETH_ALEN); @@ -2146,17 +2141,17 @@ static struct net_device *init_wifidev(struct airo_info *ai, struct net_device *ethdev) { int err; - struct net_device *dev = (struct net_device*)kmalloc(sizeof *dev,GFP_KERNEL); - if (!dev) return 0; - memset(dev, 0, sizeof(*dev)); - - strcpy(dev->name, "wifi%d"); - dev->priv = ai; - wifi_setup(dev, ethdev); + struct net_device *dev = alloc_netdev(0, "wifi%d", wifi_setup); + if (!dev) + return NULL; + dev->priv = ethdev->priv; + dev->irq = ethdev->irq; + dev->base_addr = ethdev->base_addr; + memcpy(dev->dev_addr, ethdev->dev_addr, dev->addr_len); err = register_netdev(dev); if (err<0) { - kfree(dev); - return 0; + free_netdev(dev); + return NULL; } return dev; } @@ -2272,7 +2267,7 @@ err_out_thr: kill_proc(ai->thr_pid, SIGTERM, 1); wait_for_completion(&ai->thr_exited); err_out_free: - kfree(dev); + free_netdev(dev); return NULL; } diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c index 4cd0f8d559b7..3a8da1ab582c 100644 --- a/drivers/net/wireless/orinoco.c +++ b/drivers/net/wireless/orinoco.c @@ -4129,6 +4129,8 @@ struct net_device *alloc_orinocodev(int sizeof_card, int (*hard_reset)(struct or struct orinoco_private *priv; dev = alloc_etherdev(sizeof(struct orinoco_private) + sizeof_card); + if (!dev) + return NULL; priv = (struct orinoco_private *)dev->priv; priv->ndev = dev; if (sizeof_card) diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c index 079ffd870369..0ef0d247bdcc 100644 --- a/drivers/net/wireless/wl3501_cs.c +++ b/drivers/net/wireless/wl3501_cs.c @@ -1580,7 +1580,7 @@ static void wl3501_detach(dev_link_t *link) *linkp = link->next; if (link->priv) - kfree(link->priv); + free_netdev(link->priv); kfree(link); out: return; diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c index e0e220e969d3..fb6da78eeb57 100644 --- a/drivers/s390/net/lcs.c +++ b/drivers/s390/net/lcs.c @@ -360,7 +360,7 @@ lcs_cleanup_card(struct lcs_card *card) kfree(ipm_list); } #endif - kfree(card->dev); + free_netdev(card->dev); /* Cleanup channels. */ lcs_cleanup_channel(&card->write); lcs_cleanup_channel(&card->read); @@ -1858,8 +1858,7 @@ lcs_new_device(struct ccwgroup_device *ccwgdev) lcs_stopcard(card); return 0; out: - lcs_cleanup_channel(&card->read); - lcs_cleanup_channel(&card->write); + lcs_cleanup_card(card); lcs_free_card(card); return -ENODEV; } diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c index da672160ed34..ba62eca087ac 100644 --- a/drivers/s390/net/netiucv.c +++ b/drivers/s390/net/netiucv.c @@ -1473,6 +1473,14 @@ netiucv_remove_files(struct device *dev) sysfs_remove_group(&dev->kobj, &netiucv_attr_group); } +/* + * XXX: Don't use sysfs unless you know WTF you are doing. + * This particular turd registers sysfs objects embedded into netiucv_priv + * which is kfreed without any regard to possible sysfs references. + * As the result, the wanker who'd decided that sysfs exports were too hip and + * cute to resist had generated a set of user-exploitable holes in this driver. + */ + static int netiucv_register_device(struct net_device *ndev, int ifno) { @@ -1592,6 +1600,22 @@ netiucv_remove_connection(struct iucv_connection *conn) } } +static void setup_netiucv(struct net_device *dev) +{ + dev->mtu = NETIUCV_MTU_DEFAULT; + dev->hard_start_xmit = netiucv_tx; + dev->open = netiucv_open; + dev->stop = netiucv_close; + dev->get_stats = netiucv_stats; + dev->change_mtu = netiucv_change_mtu; + dev->hard_header_len = NETIUCV_HDRLEN; + dev->addr_len = 0; + dev->type = ARPHRD_SLIP; + dev->tx_queue_len = NETIUCV_QUEUELEN_DEFAULT; + dev->flags = IFF_POINTOPOINT | IFF_NOARP; + SET_MODULE_OWNER(dev); +} + /** * Allocate and initialize everything of a net device. */ @@ -1601,16 +1625,15 @@ netiucv_init_netdevice(int ifno, char *username) struct netiucv_priv *privptr; int priv_size; - struct net_device *dev = kmalloc(sizeof(struct net_device), GFP_KERNEL); + struct net_device *dev = alloc_netdev(0, "", setup_netiucv); if (!dev) return NULL; - memset(dev, 0, sizeof(struct net_device)); sprintf(dev->name, "iucv%d", ifno); priv_size = sizeof(struct netiucv_priv); dev->priv = kmalloc(priv_size, GFP_KERNEL); if (dev->priv == NULL) { - kfree(dev); + free_netdev(dev); return NULL; } memset(dev->priv, 0, priv_size); @@ -1620,30 +1643,18 @@ netiucv_init_netdevice(int ifno, char *username) dev_fsm, DEV_FSM_LEN, GFP_KERNEL); if (privptr->fsm == NULL) { kfree(privptr); - kfree(dev); + free_netdev(dev); return NULL; } privptr->conn = netiucv_new_connection(dev, username); if (!privptr->conn) { kfree_fsm(privptr->fsm); kfree(privptr); - kfree(dev); + free_netdev(dev); return NULL; } fsm_newstate(privptr->fsm, DEV_STATE_STOPPED); - dev->mtu = NETIUCV_MTU_DEFAULT; - dev->hard_start_xmit = netiucv_tx; - dev->open = netiucv_open; - dev->stop = netiucv_close; - dev->get_stats = netiucv_stats; - dev->change_mtu = netiucv_change_mtu; - dev->hard_header_len = NETIUCV_HDRLEN; - dev->addr_len = 0; - dev->type = ARPHRD_SLIP; - dev->tx_queue_len = NETIUCV_QUEUELEN_DEFAULT; - dev->flags = IFF_POINTOPOINT | IFF_NOARP; - SET_MODULE_OWNER(dev); return dev; } diff --git a/drivers/s390/net/qeth.c b/drivers/s390/net/qeth.c index 8f660aa7ea2f..fa14910b225d 100644 --- a/drivers/s390/net/qeth.c +++ b/drivers/s390/net/qeth.c @@ -6707,15 +6707,6 @@ qeth_remove_card(struct qeth_card *card, int method) } static void -qeth_destructor(struct net_device *dev) -{ - struct qeth_card *card; - - card = (struct qeth_card *) (dev->priv); - QETH_DBF_CARD2(0, trace, "dstr", card); -} - -static void qeth_set_multicast_list(struct net_device *dev) { struct qeth_card *card = dev->priv; @@ -7655,28 +7646,11 @@ qeth_init_dev(struct net_device *dev) QETH_DBF_CARD3(0, trace, "inid", card); - dev->tx_timeout = &qeth_tx_timeout; - dev->watchdog_timeo = QETH_TX_TIMEOUT; - dev->open = qeth_open; - dev->stop = qeth_stop; - dev->set_config = qeth_set_config; - dev->hard_start_xmit = qeth_hard_start_xmit; - dev->do_ioctl = qeth_do_ioctl; - dev->get_stats = qeth_get_stats; - dev->change_mtu = qeth_change_mtu; -#ifdef QETH_VLAN - dev->vlan_rx_register = qeth_vlan_rx_register; - dev->vlan_rx_kill_vid = qeth_vlan_rx_kill_vid; -#endif dev->rebuild_header = __qeth_rebuild_header_func(card); dev->hard_header = __qeth_hard_header_func(card); dev->header_cache_update = __qeth_header_cache_update_func(card); dev->hard_header_cache = __qeth_hard_header_cache_func(card); dev->hard_header_parse = NULL; - dev->destructor = qeth_destructor; - dev->set_multicast_list = qeth_set_multicast_list; - dev->set_mac_address = qeth_set_mac_address; - dev->neigh_setup = qeth_neigh_setup; dev->flags |= qeth_get_additional_dev_flags(card->type); @@ -7694,8 +7668,6 @@ qeth_init_dev(struct net_device *dev) dev->tx_queue_len = qeth_get_device_tx_q_len(card->type); dev->hard_header_len = qeth_get_hlen(card->link_type) + card->options.add_hhlen; - dev->addr_len = OSA_ADDR_LEN; /* is ok for eth, tr, atm lane */ - SET_MODULE_OWNER(dev); netif_start_queue(dev); dev->mtu = card->initial_mtu; @@ -8358,6 +8330,28 @@ qeth_fill_qeth_card_options(struct qeth_card *card) card->options.fake_ll = DONT_FAKE_LL; } +static void qeth_setup(struct net_device *dev) +{ + dev->tx_timeout = &qeth_tx_timeout; + dev->watchdog_timeo = QETH_TX_TIMEOUT; + dev->open = qeth_open; + dev->stop = qeth_stop; + dev->set_config = qeth_set_config; + dev->hard_start_xmit = qeth_hard_start_xmit; + dev->do_ioctl = qeth_do_ioctl; + dev->get_stats = qeth_get_stats; + dev->change_mtu = qeth_change_mtu; +#ifdef QETH_VLAN + dev->vlan_rx_register = qeth_vlan_rx_register; + dev->vlan_rx_kill_vid = qeth_vlan_rx_kill_vid; +#endif + dev->set_multicast_list = qeth_set_multicast_list; + dev->set_mac_address = qeth_set_mac_address; + dev->neigh_setup = qeth_neigh_setup; + dev->addr_len = OSA_ADDR_LEN; /* is ok for eth, tr, atm lane */ + SET_MODULE_OWNER(dev); +} + static int qeth_alloc_card_stuff(struct qeth_card *card) { @@ -8385,11 +8379,9 @@ qeth_alloc_card_stuff(struct qeth_card *card) goto exit_dma2; memset(card->dma_stuff->sendbuf, 0, QETH_BUFSIZE); - card->dev = (struct net_device *) kmalloc(sizeof (struct net_device), - GFP_KERNEL); + card->dev = alloc_netdev(0, "", qeth_setup); if (!card->dev) goto exit_dev; - memset(card->dev, 0, sizeof (struct net_device)); card->stats = (struct net_device_stats *) diff --git a/drivers/usb/net/catc.c b/drivers/usb/net/catc.c index 51299e45989d..d705e815acab 100644 --- a/drivers/usb/net/catc.c +++ b/drivers/usb/net/catc.c @@ -838,7 +838,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id usb_free_urb(catc->rx_urb); if (catc->irq_urb) usb_free_urb(catc->irq_urb); - kfree(netdev); + free_netdev(netdev); kfree(catc); return -ENOMEM; } @@ -943,7 +943,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id usb_free_urb(catc->tx_urb); usb_free_urb(catc->rx_urb); usb_free_urb(catc->irq_urb); - kfree(netdev); + free_netdev(netdev); kfree(catc); return -EIO; } diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c index ecd08773201e..09c6bbe66b39 100644 --- a/drivers/usb/net/kaweth.c +++ b/drivers/usb/net/kaweth.c @@ -1150,7 +1150,7 @@ err_tx_and_rx: err_only_tx: usb_free_urb(kaweth->tx_urb); err_no_urb: - kfree(netdev); + free_netdev(netdev); err_no_netdev: kfree(kaweth); return -EIO; diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c index eabaae5e4e22..5174c9fbf4d1 100644 --- a/drivers/usb/net/pegasus.c +++ b/drivers/usb/net/pegasus.c @@ -1283,7 +1283,7 @@ out4: usb_set_intfdata(intf, NULL); free_skb_pool(pegasus); out3: - kfree(net); + free_netdev(net); out2: free_all_urbs(pegasus); out1: diff --git a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c index eb12cca50935..ec52d703aa3e 100644 --- a/drivers/usb/net/rtl8150.c +++ b/drivers/usb/net/rtl8150.c @@ -852,7 +852,7 @@ out1: free_all_urbs(dev); out: kfree(dev->intr_buff); - kfree(netdev); + free_netdev(netdev); kfree(dev); return -EIO; } diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index e3447d092f5f..35523b0ab18e 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c @@ -2922,7 +2922,7 @@ static void usbnet_disconnect (struct usb_interface *intf) if (dev->driver_info->unbind) dev->driver_info->unbind (dev, intf); - kfree(dev->net); + free_netdev(dev->net); kfree (dev); usb_put_dev (xdev); } @@ -3050,7 +3050,7 @@ out3: if (info->unbind) info->unbind (dev, udev); out2: - kfree(net); + free_netdev(net); out1: kfree(dev); out: diff --git a/include/linux/if_pppvar.h b/include/linux/if_pppvar.h deleted file mode 100644 index e79239fd31ac..000000000000 --- a/include/linux/if_pppvar.h +++ /dev/null @@ -1,138 +0,0 @@ -/* From: if_pppvar.h,v 1.2 1995/06/12 11:36:51 paulus Exp */ -/* - * if_pppvar.h - private structures and declarations for PPP. - * - * Copyright (c) 1994 The Australian National University. - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation is hereby granted, provided that the above copyright - * notice appears in all copies. This software is provided without any - * warranty, express or implied. The Australian National University - * makes no representations about the suitability of this software for - * any purpose. - * - * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY - * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF - * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO - * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, - * OR MODIFICATIONS. - * - * Copyright (c) 1989 Carnegie Mellon University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Carnegie Mellon University. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -/* - * ==FILEVERSION 990806== - * - * NOTE TO MAINTAINERS: - * If you modify this file at all, please set the above date. - * if_pppvar.h is shipped with a PPP distribution as well as with the kernel; - * if everyone increases the FILEVERSION number above, then scripts - * can do the right thing when deciding whether to install a new if_pppvar.h - * file. Don't change the format of that line otherwise, so the - * installation script can recognize it. - */ - -/* - * Supported network protocols. These values are used for - * indexing sc_npmode. - */ - -#define NP_IP 0 /* Internet Protocol */ -#define NP_IPX 1 /* IPX protocol */ -#define NP_AT 2 /* Appletalk protocol */ -#define NP_IPV6 3 /* Internet Protocol */ -#define NUM_NP 4 /* Number of NPs. */ - -#define OBUFSIZE 256 /* # chars of output buffering */ - -/* - * Structure describing each ppp unit. - */ - -struct ppp { - int magic; /* magic value for structure */ - struct ppp *next; /* unit with next index */ - unsigned long inuse; /* are we allocated? */ - int line; /* network interface unit # */ - __u32 flags; /* miscellaneous control flags */ - int mtu; /* maximum xmit frame size */ - int mru; /* maximum receive frame size */ - struct slcompress *slcomp; /* for TCP header compression */ - struct sk_buff_head xmt_q; /* frames to send from pppd */ - struct sk_buff_head rcv_q; /* frames for pppd to read */ - unsigned long xmit_busy; /* bit 0 set when xmitter busy */ - - /* Information specific to using ppp on async serial lines. */ - struct tty_struct *tty; /* ptr to TTY structure */ - struct tty_struct *backup_tty; /* TTY to use if tty gets closed */ - __u8 escape; /* 0x20 if prev char was PPP_ESC */ - __u8 toss; /* toss this frame */ - volatile __u8 tty_pushing; /* internal state flag */ - volatile __u8 woke_up; /* internal state flag */ - __u32 xmit_async_map[8]; /* 1 bit means that given control - character is quoted on output*/ - __u32 recv_async_map; /* 1 bit means that given control - character is ignored on input*/ - __u32 bytes_sent; /* Bytes sent on frame */ - __u32 bytes_rcvd; /* Bytes recvd on frame */ - - /* Async transmission information */ - struct sk_buff *tpkt; /* frame currently being sent */ - int tpkt_pos; /* how much of it we've done */ - __u16 tfcs; /* FCS so far for it */ - unsigned char *optr; /* where we're up to in sending */ - unsigned char *olim; /* points past last valid char */ - - /* Async reception information */ - struct sk_buff *rpkt; /* frame currently being rcvd */ - __u16 rfcs; /* FCS so far of rpkt */ - - /* Queues for select() functionality */ - wait_queue_head_t read_wait; /* queue for reading processes */ - - /* info for detecting idle channels */ - unsigned long last_xmit; /* time of last transmission */ - unsigned long last_recv; /* time last packet received */ - - /* Statistic information */ - struct pppstat stats; /* statistic information */ - - /* PPP compression protocol information */ - struct compressor *sc_xcomp; /* transmit compressor */ - void *sc_xc_state; /* transmit compressor state */ - struct compressor *sc_rcomp; /* receive decompressor */ - void *sc_rc_state; /* receive decompressor state */ - - enum NPmode sc_npmode[NUM_NP]; /* what to do with each NP */ - int sc_xfer; /* PID of reserved PPP table */ - char name[16]; /* space for unit name */ - struct net_device dev; /* net device structure */ - struct net_device_stats estats; /* more detailed stats */ - - /* tty output buffer */ - unsigned char obuf[OBUFSIZE]; /* buffer for characters to send */ -}; - -#define PPP_MAGIC 0x5002 -#define PPP_VERSION "2.3.7" diff --git a/include/linux/isdn.h b/include/linux/isdn.h index a704d7b489b0..777297e984e2 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -192,7 +192,6 @@ typedef struct { #include <linux/ppp_defs.h> #include <linux/if_ppp.h> -#include <linux/if_pppvar.h> #include <linux/isdn_ppp.h> #endif diff --git a/include/linux/ppp.h b/include/linux/ppp.h deleted file mode 100644 index 233f961ecf47..000000000000 --- a/include/linux/ppp.h +++ /dev/null @@ -1,4 +0,0 @@ -/* - * Back compatibility for a while. - */ -#include <linux/if_ppp.h> diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index bfc82e61d9d0..6203a5616b03 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c @@ -566,7 +566,7 @@ out_free_unregister: goto out_put_dev; out_free_newdev: - kfree(new_dev); + free_netdev(new_dev); out_unlock: rtnl_unlock(); diff --git a/net/atm/lec.c b/net/atm/lec.c index 725a52fdcafa..07395e6d042b 100644 --- a/net/atm/lec.c +++ b/net/atm/lec.c @@ -798,7 +798,7 @@ lecd_attach(struct atm_vcc *vcc, int arg) return -ENOMEM; snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i); if (register_netdev(dev_lec[i])) { - kfree(dev_lec[i]); + free_netdev(dev_lec[i]); return -EINVAL; } diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index ece601f8df1d..aca6800b9bd1 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c @@ -501,7 +501,7 @@ static int bnep_session(void *arg) __bnep_unlink_session(s); up_write(&bnep_session_sem); - kfree(dev); + free_netdev(dev); return 0; } @@ -588,7 +588,7 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock) failed: up_write(&bnep_session_sem); - kfree(dev); + free_netdev(dev); return err; } diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index e33f1cd2812b..a98019486efe 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -280,7 +280,7 @@ static struct ip_tunnel * ipgre_tunnel_locate(struct ip_tunnel_parm *parms, int nt->parms = *parms; if (register_netdevice(dev) < 0) { - kfree(dev); + free_netdev(dev); goto failed; } @@ -1276,7 +1276,7 @@ out: return err; fail: inet_del_protocol(&ipgre_protocol, IPPROTO_GRE); - kfree(ipgre_fb_tunnel_dev); + free_netdev(ipgre_fb_tunnel_dev); goto out; } diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index 0b7e4b21bdfe..71e048b1a698 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c @@ -250,7 +250,7 @@ static struct ip_tunnel * ipip_tunnel_locate(struct ip_tunnel_parm *parms, int c nt->parms = *parms; if (register_netdevice(dev) < 0) { - kfree(dev); + free_netdev(dev); goto failed; } @@ -899,7 +899,7 @@ int __init ipip_init(void) return err; fail: xfrm4_tunnel_deregister(&ipip_handler); - kfree(ipip_fb_tunnel_dev); + free_netdev(ipip_fb_tunnel_dev); goto out; } diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 6421a5f64966..a3720f2f8014 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c @@ -209,7 +209,7 @@ static struct net_device *ipmr_reg_vif(void) return NULL; if (register_netdevice(dev)) { - kfree(dev); + free_netdev(dev); return NULL; } dev->iflink = 0; diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 7f02c1901e9d..203cc05aa8fc 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c @@ -245,7 +245,7 @@ ip6_tnl_create(struct ip6_tnl_parm *p, struct ip6_tnl **pt) t->parms = *p; if ((err = register_netdevice(dev)) < 0) { - kfree(dev); + free_netdev(dev); return err; } dev_hold(dev); @@ -1118,7 +1118,7 @@ int __init ip6_tunnel_init(void) ip6ip6_fb_tnl_dev->init = ip6ip6_fb_tnl_dev_init; if ((err = register_netdev(ip6ip6_fb_tnl_dev))) { - kfree(ip6ip6_fb_tnl_dev); + free_netdev(ip6ip6_fb_tnl_dev); goto fail; } return 0; diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 80baea496a54..736cea73414b 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c @@ -187,7 +187,7 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int nt->parms = *parms; if (register_netdevice(dev) < 0) { - kfree(dev); + free_netdev(dev); goto failed; } @@ -838,6 +838,6 @@ int __init sit_init(void) return err; fail: inet_del_protocol(&sit_protocol, IPPROTO_IPV6); - kfree(ipip6_fb_tunnel_dev); + free_netdev(ipip6_fb_tunnel_dev); goto out; } diff --git a/net/irda/irlan/irlan_common.c b/net/irda/irlan/irlan_common.c index c21b4a8bdc73..dba6a072f642 100644 --- a/net/irda/irlan/irlan_common.c +++ b/net/irda/irlan/irlan_common.c @@ -224,7 +224,7 @@ struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr) IRDA_DEBUG(2, "%s(), register_netdev() failed!\n", __FUNCTION__ ); self = NULL; - kfree(dev); + free_netdev(dev); } else { rtnl_lock(); list_add_rcu(&self->dev_list, &irlans); diff --git a/net/irda/irlan/irlan_eth.c b/net/irda/irlan/irlan_eth.c index 6a9c33f6ff31..d47022c23fd4 100644 --- a/net/irda/irlan/irlan_eth.c +++ b/net/irda/irlan/irlan_eth.c @@ -60,7 +60,7 @@ void irlan_eth_setup(struct net_device *dev) dev->hard_start_xmit = irlan_eth_xmit; dev->get_stats = irlan_eth_get_stats; dev->set_multicast_list = irlan_eth_set_multicast_list; - dev->destructor = (void (*)(struct net_device *)) kfree; + dev->destructor = free_netdev; SET_MODULE_OWNER(dev); |
