Commit f5d1862d authored by Alexander Viro's avatar Alexander Viro Committed by Stephen Hemminger

[netdrvr saa9730] use alloc_etherdev, annotate bugs found but not fixed

parent b91a902e
...@@ -996,11 +996,11 @@ static void __devexit saa9730_remove_one(struct pci_dev *pdev) ...@@ -996,11 +996,11 @@ static void __devexit saa9730_remove_one(struct pci_dev *pdev)
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = pci_get_drvdata(pdev);
if (dev) { if (dev) {
unregister_netdev(dev);
if (dev->priv) if (dev->priv)
kfree(dev->priv); kfree(dev->priv);
unregister_netdev(dev);
free_netdev(dev); free_netdev(dev);
pci_release_regions(pdev); pci_release_regions(pdev);
pci_disable_device(pdev); pci_disable_device(pdev);
...@@ -1015,17 +1015,10 @@ static int lan_saa9730_init(struct net_device *dev, int ioaddr, int irq) ...@@ -1015,17 +1015,10 @@ static int lan_saa9730_init(struct net_device *dev, int ioaddr, int irq)
unsigned char ethernet_addr[6]; unsigned char ethernet_addr[6];
int ret = 0; int ret = 0;
dev = init_etherdev(dev, 0);
if (!dev)
return -ENOMEM;
dev->open = lan_saa9730_open_fail; dev->open = lan_saa9730_open_fail;
if (get_ethernet_addr(ethernet_addr)) { if (get_ethernet_addr(ethernet_addr))
ret = -ENODEV; return -ENODEV;
goto out;
}
memcpy(dev->dev_addr, ethernet_addr, 6); memcpy(dev->dev_addr, ethernet_addr, 6);
dev->base_addr = ioaddr; dev->base_addr = ioaddr;
...@@ -1040,10 +1033,8 @@ static int lan_saa9730_init(struct net_device *dev, int ioaddr, int irq) ...@@ -1040,10 +1033,8 @@ static int lan_saa9730_init(struct net_device *dev, int ioaddr, int irq)
GFP_DMA | GFP_KERNEL) GFP_DMA | GFP_KERNEL)
+ 7) & ~7); + 7) & ~7);
if (!lp) { if (!lp)
ret = -ENOMEM; return -ENOMEM;
goto out;
}
dev->priv = lp; dev->priv = lp;
memset(lp, 0, sizeof(*lp)); memset(lp, 0, sizeof(*lp));
...@@ -1057,6 +1048,7 @@ static int lan_saa9730_init(struct net_device *dev, int ioaddr, int irq) ...@@ -1057,6 +1048,7 @@ static int lan_saa9730_init(struct net_device *dev, int ioaddr, int irq)
SAA9730_EVM_REGS_ADDR); SAA9730_EVM_REGS_ADDR);
/* Allocate LAN RX/TX frame buffer space. */ /* Allocate LAN RX/TX frame buffer space. */
/* FIXME: a leak */
if ((ret = lan_saa9730_allocate_buffers(lp))) if ((ret = lan_saa9730_allocate_buffers(lp)))
goto out; goto out;
...@@ -1095,39 +1087,45 @@ static int lan_saa9730_init(struct net_device *dev, int ioaddr, int irq) ...@@ -1095,39 +1087,45 @@ static int lan_saa9730_init(struct net_device *dev, int ioaddr, int irq)
dev->watchdog_timeo = (HZ >> 1); dev->watchdog_timeo = (HZ >> 1);
dev->dma = 0; dev->dma = 0;
ret = register_netdev(dev);
if (ret)
goto out;
return 0; return 0;
out: out:
if (dev) {
if (dev->priv) if (dev->priv)
kfree(dev->priv); kfree(dev->priv);
unregister_netdevice(dev);
free_netdev(dev); free_netdev(dev);
}
return ret; return ret;
} }
static int __devinit saa9730_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) static int __devinit saa9730_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
struct net_device *dev = NULL; struct net_device *dev;
unsigned int pci_ioaddr; unsigned int pci_ioaddr;
int err; int err;
if (lan_saa9730_debug > 1) if (lan_saa9730_debug > 1)
printk("saa9730.c: PCI bios is present, checking for devices...\n"); printk("saa9730.c: PCI bios is present, checking for devices...\n");
err = -ENOMEM;
dev = alloc_etherdev(0);
if (!dev)
goto out;
SET_MODULE_OWNER(dev);
err = pci_enable_device(pdev); err = pci_enable_device(pdev);
if (err) { if (err) {
printk(KERN_ERR "Cannot enable PCI device, aborting.\n"); printk(KERN_ERR "Cannot enable PCI device, aborting.\n");
goto out; goto out1;
} }
err = pci_request_regions(pdev, DRV_MODULE_NAME); err = pci_request_regions(pdev, DRV_MODULE_NAME);
if (err) { if (err) {
printk(KERN_ERR "Cannot obtain PCI resources, aborting.\n"); printk(KERN_ERR "Cannot obtain PCI resources, aborting.\n");
goto out_disable_pdev; goto out2;
} }
pci_irq_line = pdev->irq; pci_irq_line = pdev->irq;
...@@ -1142,16 +1140,17 @@ static int __devinit saa9730_init_one(struct pci_dev *pdev, const struct pci_dev ...@@ -1142,16 +1140,17 @@ static int __devinit saa9730_init_one(struct pci_dev *pdev, const struct pci_dev
err = lan_saa9730_init(dev, pci_ioaddr, pci_irq_line); err = lan_saa9730_init(dev, pci_ioaddr, pci_irq_line);
if (err) { if (err) {
printk("Lan init failed"); printk("Lan init failed");
goto out_disable_pdev; goto out2;
} }
pci_set_drvdata(pdev, dev); pci_set_drvdata(pdev, dev);
return 0; return 0;
out_disable_pdev: out2:
pci_disable_device(pdev); pci_disable_device(pdev);
out: out1:
pci_set_drvdata(pdev, NULL); free_netdev(dev);
out:
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment