[netdrvr] Fix register_netdev() races in older ISA net drivers
author <herbert@gondor.apana.org.au> <>
Fri, 13 May 2005 00:11:55 +0000 (20:11 -0400)
committerJeff Garzik <jgarzik@pobox.com>
Fri, 13 May 2005 00:11:55 +0000 (20:11 -0400)
21 files changed:
drivers/net/3c503.c
drivers/net/3c515.c
drivers/net/3c523.c
drivers/net/ac3200.c
drivers/net/cs89x0.c
drivers/net/e2100.c
drivers/net/eepro.c
drivers/net/eexpress.c
drivers/net/es3210.c
drivers/net/eth16i.c
drivers/net/hp-plus.c
drivers/net/hp.c
drivers/net/hp100.c
drivers/net/isa-skeleton.c
drivers/net/lance.c
drivers/net/lne390.c
drivers/net/ne-h8300.c
drivers/net/ne.c
drivers/net/ne2.c
drivers/net/smc-ultra.c
drivers/net/wd.c

index 29dfd47f41d2b4ff10275a135cae7ef604eff17e..5c5eebdb69146e5fb83f86ff6870f796d5e95933 100644 (file)
@@ -171,12 +171,7 @@ struct net_device * __init el2_probe(int unit)
        err = do_el2_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);
@@ -356,6 +351,10 @@ el2_probe1(struct net_device *dev, int ioaddr)
     dev->poll_controller = ei_poll;
 #endif
 
+    retval = register_netdev(dev);
+    if (retval)
+       goto out1;
+
     if (dev->mem_start)
        printk("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n",
                dev->name, ei_status.name, (wordlength+1)<<3,
@@ -715,11 +714,8 @@ init_module(void)
                dev->base_addr = io[this_dev];
                dev->mem_end = xcvr[this_dev];  /* low 4bits = xcvr sel. */
                if (do_el2_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_el2[found++] = dev;
-                               continue;
-                       }
-                       cleanup_card(dev);
+                       dev_el2[found++] = dev;
+                       continue;
                }
                free_netdev(dev);
                printk(KERN_WARNING "3c503.c: No 3c503 card found (i/o = 0x%x).\n", io[this_dev]);
index c4cf4fcd13444eedec8e5693b69d84b782d70e1f..d272ea36a578b09c3aaa675ae4133124731fd271 100644 (file)
@@ -365,7 +365,7 @@ static int nopnp;
 #endif /* __ISAPNP__ */
 
 static struct net_device *corkscrew_scan(int unit);
-static void corkscrew_setup(struct net_device *dev, int ioaddr,
+static int corkscrew_setup(struct net_device *dev, int ioaddr,
                            struct pnp_dev *idev, int card_number);
 static int corkscrew_open(struct net_device *dev);
 static void corkscrew_timer(unsigned long arg);
@@ -539,10 +539,9 @@ static struct net_device *corkscrew_scan(int unit)
                        printk(KERN_INFO "3c515 Resource configuration register %#4.4x, DCR %4.4x.\n",
                                inl(ioaddr + 0x2002), inw(ioaddr + 0x2000));
                        /* irq = inw(ioaddr + 0x2002) & 15; */ /* Use the irq from isapnp */
-                       corkscrew_setup(dev, ioaddr, idev, cards_found++);
                        SET_NETDEV_DEV(dev, &idev->dev);
                        pnp_cards++;
-                       err = register_netdev(dev);
+                       err = corkscrew_setup(dev, ioaddr, idev, cards_found++);
                        if (!err)
                                return dev;
                        cleanup_card(dev);
@@ -558,8 +557,7 @@ no_pnp:
 
                printk(KERN_INFO "3c515 Resource configuration register %#4.4x, DCR %4.4x.\n",
                     inl(ioaddr + 0x2002), inw(ioaddr + 0x2000));
-               corkscrew_setup(dev, ioaddr, NULL, cards_found++);
-               err = register_netdev(dev);
+               err = corkscrew_setup(dev, ioaddr, NULL, cards_found++);
                if (!err)
                        return dev;
                cleanup_card(dev);
@@ -568,7 +566,7 @@ no_pnp:
        return NULL;
 }
 
-static void corkscrew_setup(struct net_device *dev, int ioaddr,
+static int corkscrew_setup(struct net_device *dev, int ioaddr,
                            struct pnp_dev *idev, int card_number)
 {
        struct corkscrew_private *vp = netdev_priv(dev);
@@ -691,6 +689,8 @@ static void corkscrew_setup(struct net_device *dev, int ioaddr,
        dev->get_stats = &corkscrew_get_stats;
        dev->set_multicast_list = &set_rx_mode;
        dev->ethtool_ops = &netdev_ethtool_ops;
+
+       return register_netdev(dev);
 }
 \f
 
index 8f6b2fa13e283665c9ad9744f52f912e08f0b6b5..1247a25f109381e214a6256d2f6d22b59ce4fe6b 100644 (file)
@@ -572,6 +572,10 @@ static int __init do_elmc_probe(struct net_device *dev)
         dev->flags&=~IFF_MULTICAST;     /* Multicast doesn't work */
 #endif
 
+       retval = register_netdev(dev);
+       if (retval)
+               goto err_out;
+
        return 0;
 err_out:
        mca_set_adapter_procfn(slot, NULL, NULL);
@@ -600,12 +604,7 @@ struct net_device * __init elmc_probe(int unit)
        err = do_elmc_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);
@@ -1288,12 +1287,9 @@ int init_module(void)
                dev->irq=irq[this_dev];
                dev->base_addr=io[this_dev];
                if (do_elmc_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_elmc[this_dev] = dev;
-                               found++;
-                               continue;
-                       }
-                       cleanup_card(dev);
+                       dev_elmc[this_dev] = dev;
+                       found++;
+                       continue;
                }
                free_netdev(dev);
                if (io[this_dev]==0)
index 24fba36b5c1d8b8f3020df32ff43e87817222423..91791ba3776930bb8354ad691680ac00e0882b85 100644 (file)
@@ -146,12 +146,7 @@ struct net_device * __init ac3200_probe(int unit)
        err = do_ac3200_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);
@@ -273,7 +268,14 @@ static int __init ac_probe1(int ioaddr, struct net_device *dev)
        dev->poll_controller = ei_poll;
 #endif
        NS8390_init(dev, 0);
+
+       retval = register_netdev(dev);
+       if (retval)
+               goto out2;
        return 0;
+out2:
+       if (ei_status.reg0)
+               iounmap((void *)dev->mem_start);
 out1:
        free_irq(dev->irq, dev);
 out:
@@ -392,11 +394,8 @@ init_module(void)
                dev->base_addr = io[this_dev];
                dev->mem_start = mem[this_dev];         /* Currently ignored by driver */
                if (do_ac3200_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_ac32[found++] = dev;
-                               continue;
-                       }
-                       cleanup_card(dev);
+                       dev_ac32[found++] = dev;
+                       continue;
                }
                free_netdev(dev);
                printk(KERN_WARNING "ac3200.c: No ac3200 card found (i/o = 0x%x).\n", io[this_dev]);
index 5c5f540da26a28618f7c1f2e017039fe713d4f1e..25e4495de79eed0d44654cdc41dba03cab03162a 100644 (file)
@@ -319,13 +319,7 @@ struct net_device * __init cs89x0_probe(int unit)
        }
        if (err)
                goto out;
-       err = register_netdev(dev);
-       if (err)
-               goto out1;
        return dev;
-out1:
-       outw(PP_ChipID, dev->base_addr + ADD_PORT);
-       release_region(dev->base_addr, NETCARD_IO_EXTENT);
 out:
        free_netdev(dev);
        printk(KERN_WARNING "cs89x0: no cs8900 or cs8920 detected.  Be sure to disable PnP with SETUP\n");
@@ -735,7 +729,13 @@ printk("PP_addr=0x%x\n", inw(ioaddr + ADD_PORT));
        printk("\n");
        if (net_debug)
                printk("cs89x0_probe1() successful\n");
+
+       retval = register_netdev(dev);
+       if (retval)
+               goto out3;
        return 0;
+out3:
+       outw(PP_ChipID, dev->base_addr + ADD_PORT);
 out2:
        release_region(ioaddr & ~3, NETCARD_IO_EXTENT);
 out1:
@@ -1831,13 +1831,6 @@ init_module(void)
        if (ret)
                goto out;
 
-        if (register_netdev(dev) != 0) {
-                printk(KERN_ERR "cs89x0.c: No card found at 0x%x\n", io);
-                ret = -ENXIO;
-               outw(PP_ChipID, dev->base_addr + ADD_PORT);
-               release_region(dev->base_addr, NETCARD_IO_EXTENT);
-               goto out;
-        }
        dev_cs89x0 = dev;
        return 0;
 out:
index 51c9fa2608306e751edd2348d30fe78c013bfaf4..f5a4dd7d856440d5ae6b5a41784ee80952dec4b3 100644 (file)
@@ -162,12 +162,7 @@ struct net_device * __init e2100_probe(int unit)
        err = do_e2100_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);
@@ -286,6 +281,9 @@ static int __init e21_probe1(struct net_device *dev, int ioaddr)
 #endif
        NS8390_init(dev, 0);
 
+       retval = register_netdev(dev);
+       if (retval)
+               goto out;
        return 0;
 out:
        release_region(ioaddr, E21_IO_EXTENT);
@@ -453,11 +451,8 @@ init_module(void)
                dev->mem_start = mem[this_dev];
                dev->mem_end = xcvr[this_dev];  /* low 4bits = xcvr sel. */
                if (do_e2100_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_e21[found++] = dev;
-                               continue;
-                       }
-                       cleanup_card(dev);
+                       dev_e21[found++] = dev;
+                       continue;
                }
                free_netdev(dev);
                printk(KERN_WARNING "e2100.c: No E2100 card found (i/o = 0x%x).\n", io[this_dev]);
index cd2475683027703d588727ecfbd481ad877040c0..dcb3028bb60f8d75f73e68ef1d0e32eb7df5ccfb 100644 (file)
@@ -600,12 +600,7 @@ struct net_device * __init eepro_probe(int unit)
        err = do_eepro_probe(dev);
        if (err)
                goto out;
-       err = register_netdev(dev);
-       if (err)
-               goto out1;
        return dev;
-out1:
-       release_region(dev->base_addr, EEPRO_IO_EXTENT);
 out:
        free_netdev(dev);
        return ERR_PTR(err);
@@ -758,6 +753,7 @@ static int __init eepro_probe1(struct net_device *dev, int autoprobe)
        int i;
        struct eepro_local *lp;
        int ioaddr = dev->base_addr;
+       int err;
 
        /* Grab the region so we can find another board if autoIRQ fails. */
        if (!request_region(ioaddr, EEPRO_IO_EXTENT, DRV_NAME)) { 
@@ -873,10 +869,16 @@ static int __init eepro_probe1(struct net_device *dev, int autoprobe)
 
        /* reset 82595 */
        eepro_reset(ioaddr);
+
+       err = register_netdev(dev);
+       if (err)
+               goto err;
        return 0;
 exit:
+       err = -ENODEV;
+err:
        release_region(dev->base_addr, EEPRO_IO_EXTENT);
-       return -ENODEV;
+       return err;
 }
 
 /* Open/initialize the board.  This is called (in the current kernel)
@@ -1834,11 +1836,8 @@ init_module(void)
                dev->irq = irq[i];
 
                if (do_eepro_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_eepro[n_eepro++] = dev;
-                               continue;
-                       }
-                       release_region(dev->base_addr, EEPRO_IO_EXTENT);
+                       dev_eepro[n_eepro++] = dev;
+                       continue;
                }
                free_netdev(dev);
                break;
index fc8e7947b3346bf0b282da1c73af096529a45aa0..82bd356e4f3abf8d2ecf7ff909f8ce4b7bda149f 100644 (file)
@@ -436,11 +436,8 @@ struct net_device * __init express_probe(int unit)
        netdev_boot_setup_check(dev);
 
        err = do_express_probe(dev);
-       if (!err) {
-               err = register_netdev(dev);
-               if (!err)
-                       return dev;
-       }
+       if (!err)
+               return dev;
        free_netdev(dev);
        return ERR_PTR(err);
 }
@@ -1205,7 +1202,8 @@ static int __init eexp_hw_probe(struct net_device *dev, unsigned short ioaddr)
        dev->set_multicast_list = &eexp_set_multicast;
        dev->tx_timeout = eexp_timeout;
        dev->watchdog_timeo = 2*HZ;
-       return 0;
+
+       return register_netdev(dev);
 }
 
 /*
@@ -1716,7 +1714,7 @@ int init_module(void)
                                break;
                        printk(KERN_NOTICE "eexpress.c: Module autoprobe not recommended, give io=xx.\n");
                }
-               if (do_express_probe(dev) == 0 && register_netdev(dev) == 0) {
+               if (do_express_probe(dev) == 0) {
                        dev_eexp[this_dev] = dev;
                        found++;
                        continue;
index f1e8150ed2a0918882a4654bc2564e54064e91e2..50f8e23bb9e503782693aa7a7c2f8b76c564f983 100644 (file)
@@ -177,12 +177,7 @@ struct net_device * __init es_probe(int unit)
        err = do_es_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);
@@ -310,6 +305,10 @@ static int __init es_probe1(struct net_device *dev, int ioaddr)
        dev->poll_controller = ei_poll;
 #endif
        NS8390_init(dev, 0);
+
+       retval = register_netdev(dev);
+       if (retval)
+               goto out1;
        return 0;
 out1:
        free_irq(dev->irq, dev);
@@ -445,11 +444,8 @@ init_module(void)
                dev->base_addr = io[this_dev];
                dev->mem_start = mem[this_dev];
                if (do_es_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_es3210[found++] = dev;
-                               continue;
-                       }
-                       cleanup_card(dev);
+                       dev_es3210[found++] = dev;
+                       continue;
                }
                free_netdev(dev);
                printk(KERN_WARNING "es3210.c: No es3210 card found (i/o = 0x%x).\n", io[this_dev]);
index ccae6ba5f7c591b90194291ddfe2e4c2f91acf0f..f32a6b3acb2a4b5dbd97921f77c1be45cfb28b71 100644 (file)
@@ -473,13 +473,7 @@ struct net_device * __init eth16i_probe(int unit)
        err = do_eth16i_probe(dev);
        if (err)
                goto out;
-       err = register_netdev(dev);
-       if (err)
-               goto out1;
        return dev;
-out1:
-       free_irq(dev->irq, dev);
-       release_region(dev->base_addr, ETH16I_IO_EXTENT);
 out:
        free_netdev(dev);
        return ERR_PTR(err);
@@ -569,7 +563,13 @@ static int __init eth16i_probe1(struct net_device *dev, int ioaddr)
        dev->tx_timeout         = eth16i_timeout;
        dev->watchdog_timeo     = TX_TIMEOUT;
        spin_lock_init(&lp->lock);
+
+       retval = register_netdev(dev);
+       if (retval)
+               goto out1;
        return 0;
+out1:
+       free_irq(dev->irq, dev);
 out:
        release_region(ioaddr, ETH16I_IO_EXTENT);
        return retval;
@@ -1462,12 +1462,8 @@ int init_module(void)
                }
 
                if (do_eth16i_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_eth16i[found++] = dev;
-                               continue;
-                       }
-                       free_irq(dev->irq, dev);
-                       release_region(dev->base_addr, ETH16I_IO_EXTENT);
+                       dev_eth16i[found++] = dev;
+                       continue;
                }
                printk(KERN_WARNING "eth16i.c No Eth16i card found (i/o = 0x%x).\n",
                       io[this_dev]);
index 4834314b676dca0dd87f426ea0443f691eef96d4..0abf5dd08b4c5030e4c1b26021eb7f969fef20d2 100644 (file)
@@ -159,12 +159,7 @@ struct net_device * __init hp_plus_probe(int unit)
        err = do_hpp_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);
@@ -271,6 +266,9 @@ static int __init hpp_probe1(struct net_device *dev, int ioaddr)
        /* Leave the 8390 and HP chip reset. */
        outw(inw(ioaddr + HPP_OPTION) & ~EnableIRQ, ioaddr + HPP_OPTION);
 
+       retval = register_netdev(dev);
+       if (retval)
+               goto out;
        return 0;
 out:
        release_region(ioaddr, HP_IO_EXTENT);
@@ -463,11 +461,8 @@ init_module(void)
                dev->irq = irq[this_dev];
                dev->base_addr = io[this_dev];
                if (do_hpp_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_hpp[found++] = dev;
-                               continue;
-                       }
-                       cleanup_card(dev);
+                       dev_hpp[found++] = dev;
+                       continue;
                }
                free_netdev(dev);
                printk(KERN_WARNING "hp-plus.c: No HP-Plus card found (i/o = 0x%x).\n", io[this_dev]);
index 026888611d6fef7b364fe356e1fdc2c8cbea98ea..59cf841b14abc06ad2fa11f44ca55ac0dfa6f157 100644 (file)
@@ -123,12 +123,7 @@ struct net_device * __init hp_probe(int unit)
        err = do_hp_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);
@@ -227,7 +222,12 @@ static int __init hp_probe1(struct net_device *dev, int ioaddr)
        ei_status.block_output = &hp_block_output;
        hp_init_card(dev);
 
+       retval = register_netdev(dev);
+       if (retval)
+               goto out1;
        return 0;
+out1:
+       free_irq(dev->irq, dev);
 out:
        release_region(ioaddr, HP_IO_EXTENT);
        return retval;
@@ -432,11 +432,8 @@ init_module(void)
                dev->irq = irq[this_dev];
                dev->base_addr = io[this_dev];
                if (do_hp_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_hp[found++] = dev;
-                               continue;
-                       }
-                       cleanup_card(dev);
+                       dev_hp[found++] = dev;
+                       continue;
                }
                free_netdev(dev);
                printk(KERN_WARNING "hp.c: No HP card found (i/o = 0x%x).\n", io[this_dev]);
index b3a898c5a585b73ec55a5278e3ed21d892e19f4a..c9d1a86d95948b74a0f4ec9555f9cc2fa072ef04 100644 (file)
@@ -417,12 +417,7 @@ struct net_device * __init hp100_probe(int unit)
        if (err)
                goto out;
 
-       err = register_netdev(dev);
-       if (err)
-               goto out1;
        return dev;
- out1:
-       release_region(dev->base_addr, HP100_REGION_SIZE);
  out:
        free_netdev(dev);
        return ERR_PTR(err);
@@ -776,11 +771,22 @@ static int __devinit hp100_probe1(struct net_device *dev, int ioaddr,
                printk("Warning! Link down.\n");
        }
 
+       err = register_netdev(dev);
+       if (err)
+               goto out3;
+
        return 0;
+out3:
+       if (local_mode == 1)
+               pci_free_consistent(lp->pci_dev, MAX_RINGSIZE + 0x0f, 
+                                   lp->page_vaddr_algn, 
+                                   virt_to_whatever(dev, lp->page_vaddr_algn));
+       if (mem_ptr_virt)
+               iounmap(mem_ptr_virt);
 out2:
        release_region(ioaddr, HP100_REGION_SIZE);
 out1:
-       return -ENODEV;
+       return err;
 }
 
 /* This procedure puts the card into a stable init state */
@@ -2875,18 +2881,12 @@ static int __init hp100_eisa_probe (struct device *gendev)
        if (err)
                goto out1;
 
-       err = register_netdev(dev);
-       if (err)
-               goto out2;
-       
 #ifdef HP100_DEBUG
        printk("hp100: %s: EISA adapter found at 0x%x\n", dev->name, 
               dev->base_addr);
 #endif
        gendev->driver_data = dev;
        return 0;
- out2:
-       release_region(dev->base_addr, HP100_REGION_SIZE);
  out1:
        free_netdev(dev);
        return err;
@@ -2951,17 +2951,12 @@ static int __devinit hp100_pci_probe (struct pci_dev *pdev,
        err = hp100_probe1(dev, ioaddr, HP100_BUS_PCI, pdev);
        if (err) 
                goto out1;
-       err = register_netdev(dev);
-       if (err)
-               goto out2;
        
 #ifdef HP100_DEBUG
        printk("hp100: %s: PCI adapter found at 0x%x\n", dev->name, ioaddr);
 #endif
        pci_set_drvdata(pdev, dev);
        return 0;
- out2:
-       release_region(dev->base_addr, HP100_REGION_SIZE);
  out1:
        free_netdev(dev);
  out0:
@@ -3032,15 +3027,9 @@ static int __init hp100_isa_init(void)
                SET_MODULE_OWNER(dev);
 
                err = hp100_isa_probe(dev, hp100_port[i]);
-               if (!err) {
-                       err = register_netdev(dev);
-                       if (!err) 
-                               hp100_devlist[cards++] = dev;
-                       else
-                               release_region(dev->base_addr, HP100_REGION_SIZE);
-               }
-
-               if (err)
+               if (!err)
+                       hp100_devlist[cards++] = dev;
+               else
                        free_netdev(dev);
        }
 
index 50bebb55e9ee4c2293fe10423d8639fe3f65b6a6..88ae8a04fabc0532cd8e883eb9b6781b117f9839 100644 (file)
@@ -176,12 +176,7 @@ struct net_device * __init netcard_probe(int unit)
        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);
@@ -316,7 +311,15 @@ static int __init netcard_probe1(struct net_device *dev, int ioaddr)
 
         dev->tx_timeout                = &net_tx_timeout;
         dev->watchdog_timeo    = MY_TX_TIMEOUT; 
+
+       err = register_netdev(dev);
+       if (err)
+               goto out2;
        return 0;
+out2:
+#ifdef jumpered_dma
+       free_dma(dev->dma);
+#endif
 out1:
 #ifdef jumpered_interrupts
        free_irq(dev->irq, dev);
@@ -691,11 +694,8 @@ int init_module(void)
        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);
+               this_device = dev;
+               return 0;
        }
        free_netdev(dev);
        return -ENXIO;
index dec557fb6a99fe47bfe5124c8d70e0e5f39453e4..ca90f0d1e4b0f257e75e14473eb2ed535754e0f8 100644 (file)
@@ -356,11 +356,8 @@ int init_module(void)
                dev->base_addr = io[this_dev];
                dev->dma = dma[this_dev];
                if (do_lance_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_lance[found++] = dev;
-                               continue;
-                       }
-                       cleanup_card(dev);
+                       dev_lance[found++] = dev;
+                       continue;
                }
                free_netdev(dev);
                break;
@@ -448,12 +445,7 @@ struct net_device * __init lance_probe(int unit)
        err = do_lance_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);
@@ -724,6 +716,9 @@ static int __init lance_probe1(struct net_device *dev, int ioaddr, int irq, int
        dev->tx_timeout = lance_tx_timeout;
        dev->watchdog_timeo = TX_TIMEOUT;
 
+       err = register_netdev(dev);
+       if (err)
+               goto out_dma;
        return 0;
 out_dma:
        if (dev->dma != 4)
index 179a97c0af69de8f3f692fee055423becebba788..27f0d8ac4c40d99a869e2cd297007dbeeb487d0e 100644 (file)
@@ -167,12 +167,7 @@ struct net_device * __init lne390_probe(int unit)
        err = do_lne390_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);
@@ -296,7 +291,14 @@ static int __init lne390_probe1(struct net_device *dev, int ioaddr)
        dev->poll_controller = ei_poll;
 #endif
        NS8390_init(dev, 0);
+
+       ret = register_netdev(dev);
+       if (ret)
+               goto unmap;
        return 0;
+unmap:
+       if (ei_status.reg0)
+               iounmap((void *)dev->mem_start);
 cleanup:
        free_irq(dev->irq, dev);
        return ret;
@@ -426,11 +428,8 @@ int init_module(void)
                dev->base_addr = io[this_dev];
                dev->mem_start = mem[this_dev];
                if (do_lne390_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_lne[found++] = dev;
-                               continue;
-                       }
-                       cleanup_card(dev);
+                       dev_lne[found++] = dev;
+                       continue;
                }
                free_netdev(dev);
                printk(KERN_WARNING "lne390.c: No LNE390 card found (i/o = 0x%x).\n", io[this_dev]);
index 84e291e249357db7cc2f4a7b756bbb900a600f13..8f40368cf2e9ba0b9d9b642b27044630e2e2983b 100644 (file)
@@ -180,12 +180,7 @@ struct net_device * __init ne_probe(int unit)
        err = do_ne_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);
@@ -325,8 +320,13 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr)
        dev->poll_controller = ei_poll;
 #endif
        NS8390_init(dev, 0);
-       return 0;
 
+       ret = register_netdev(dev);
+       if (ret)
+               goto out_irq;
+       return 0;
+out_irq:
+       free_irq(dev->irq, dev);
 err_out:
        release_region(ioaddr, NE_IO_EXTENT);
        return ret;
@@ -633,11 +633,8 @@ int init_module(void)
                err = init_reg_offset(dev, dev->base_addr);
                if (!err) {
                        if (do_ne_probe(dev) == 0) {
-                               if (register_netdev(dev) == 0) {
-                                       dev_ne[found++] = dev;
-                                       continue;
-                               }
-                               cleanup_card(dev);
+                               dev_ne[found++] = dev;
+                               continue;
                        }
                }
                free_netdev(dev);
index 496433902adee0740c94f251d7519ea26f8fddb0..6c57096aa2e1a82db4127e71662e5e30ce49aade 100644 (file)
@@ -229,12 +229,7 @@ struct net_device * __init ne_probe(int unit)
        err = do_ne_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);
@@ -534,8 +529,14 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr)
        dev->poll_controller = ei_poll;
 #endif
        NS8390_init(dev, 0);
+
+       ret = register_netdev(dev);
+       if (ret)
+               goto out_irq;
        return 0;
 
+out_irq:
+       free_irq(dev->irq, dev);
 err_out:
        release_region(ioaddr, NE_IO_EXTENT);
        return ret;
@@ -826,11 +827,8 @@ int init_module(void)
                dev->mem_end = bad[this_dev];
                dev->base_addr = io[this_dev];
                if (do_ne_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_ne[found++] = dev;
-                               continue;
-                       }
-                       cleanup_card(dev);
+                       dev_ne[found++] = dev;
+                       continue;
                }
                free_netdev(dev);
                if (found)
index 6ebef27dbfaea890ec85a9fb54c3d09ae81ec224..6d62ada85de61c03eb90f7399dee5657df1a9578 100644 (file)
@@ -301,12 +301,7 @@ struct net_device * __init ne2_probe(int unit)
        err = do_ne2_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);
@@ -517,7 +512,14 @@ static int __init ne2_probe1(struct net_device *dev, int slot)
        dev->poll_controller = ei_poll;
 #endif
        NS8390_init(dev, 0);
+
+       retval = register_netdev(dev);
+       if (retval)
+               goto out1;
        return 0;
+out1:
+       mca_set_adapter_procfn( ei_status.priv, NULL, NULL);
+       free_irq(dev->irq, dev);
 out:
        release_region(base_addr, NE_IO_EXTENT);
        return retval;
@@ -798,11 +800,8 @@ int init_module(void)
                dev->mem_end = bad[this_dev];
                dev->base_addr = io[this_dev];
                if (do_ne2_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_ne[found++] = dev;
-                               continue;
-                       }
-                       cleanup_card(dev);
+                       dev_ne[found++] = dev;
+                       continue;
                }
                free_netdev(dev);
                break;
index b564c677c6d25542a75a06a21e4d13f9adc0851f..6d9dae60a697050c1d7d1e8f4665420f0ac65074 100644 (file)
@@ -194,12 +194,7 @@ struct net_device * __init ultra_probe(int unit)
        err = do_ultra_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);
@@ -325,6 +320,9 @@ static int __init ultra_probe1(struct net_device *dev, int ioaddr)
 #endif
        NS8390_init(dev, 0);
 
+       retval = register_netdev(dev);
+       if (retval)
+               goto out;
        return 0;
 out:
        release_region(ioaddr, ULTRA_IO_EXTENT);
@@ -583,11 +581,8 @@ init_module(void)
                dev->irq = irq[this_dev];
                dev->base_addr = io[this_dev];
                if (do_ultra_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_ultra[found++] = dev;
-                               continue;
-                       }
-                       cleanup_card(dev);
+                       dev_ultra[found++] = dev;
+                       continue;
                }
                free_netdev(dev);
                printk(KERN_WARNING "smc-ultra.c: No SMC Ultra card found (i/o = 0x%x).\n", io[this_dev]);
index 1f05d9bd05e40b30b80bfaa7c33e4b1a68f6ae14..b03feae459fcf335db90ca08d7d8506b64c86779 100644 (file)
@@ -149,12 +149,7 @@ struct net_device * __init wd_probe(int unit)
        err = do_wd_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);
@@ -164,6 +159,7 @@ out:
 static int __init wd_probe1(struct net_device *dev, int ioaddr)
 {
        int i;
+       int err;
        int checksum = 0;
        int ancient = 0;                        /* An old card without config registers. */
        int word16 = 0;                         /* 0 = 8 bit, 1 = 16 bit */
@@ -356,7 +352,10 @@ static int __init wd_probe1(struct net_device *dev, int ioaddr)
                outb(inb(ioaddr+4)|0x80, ioaddr+4);
 #endif
 
-       return 0;
+       err = register_netdev(dev);
+       if (err)
+               free_irq(dev->irq, dev);
+       return err;
 }
 
 static int
@@ -527,11 +526,8 @@ init_module(void)
                dev->mem_start = mem[this_dev];
                dev->mem_end = mem_end[this_dev];
                if (do_wd_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_wd[found++] = dev;
-                               continue;
-                       }
-                       cleanup_card(dev);
+                       dev_wd[found++] = dev;
+                       continue;
                }
                free_netdev(dev);
                printk(KERN_WARNING "wd.c: No wd80x3 card found (i/o = 0x%x).\n", io[this_dev]);