uli526x: fix regions leak in driver probe error path.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com> Ack-by: Grant Grundler <grundler@parisc-linux.org>
This commit is contained in:
parent
7deb118217
commit
5e58deb917
|
@ -313,9 +313,9 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
|
||||||
goto err_out_disable;
|
goto err_out_disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pci_request_regions(pdev, DRV_NAME)) {
|
err = pci_request_regions(pdev, DRV_NAME);
|
||||||
|
if (err < 0) {
|
||||||
pr_err("Failed to request PCI regions\n");
|
pr_err("Failed to request PCI regions\n");
|
||||||
err = -ENODEV;
|
|
||||||
goto err_out_disable;
|
goto err_out_disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,18 +323,15 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
|
||||||
db = netdev_priv(dev);
|
db = netdev_priv(dev);
|
||||||
|
|
||||||
/* Allocate Tx/Rx descriptor memory */
|
/* Allocate Tx/Rx descriptor memory */
|
||||||
|
err = -ENOMEM;
|
||||||
|
|
||||||
db->desc_pool_ptr = pci_alloc_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, &db->desc_pool_dma_ptr);
|
db->desc_pool_ptr = pci_alloc_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, &db->desc_pool_dma_ptr);
|
||||||
if(db->desc_pool_ptr == NULL)
|
if (!db->desc_pool_ptr)
|
||||||
{
|
goto err_out_release;
|
||||||
err = -ENOMEM;
|
|
||||||
goto err_out_nomem;
|
|
||||||
}
|
|
||||||
db->buf_pool_ptr = pci_alloc_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, &db->buf_pool_dma_ptr);
|
db->buf_pool_ptr = pci_alloc_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, &db->buf_pool_dma_ptr);
|
||||||
if(db->buf_pool_ptr == NULL)
|
if (!db->buf_pool_ptr)
|
||||||
{
|
goto err_out_free_tx_desc;
|
||||||
err = -ENOMEM;
|
|
||||||
goto err_out_nomem;
|
|
||||||
}
|
|
||||||
|
|
||||||
db->first_tx_desc = (struct tx_desc *) db->desc_pool_ptr;
|
db->first_tx_desc = (struct tx_desc *) db->desc_pool_ptr;
|
||||||
db->first_tx_desc_dma = db->desc_pool_dma_ptr;
|
db->first_tx_desc_dma = db->desc_pool_dma_ptr;
|
||||||
|
@ -387,7 +384,7 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
|
||||||
}
|
}
|
||||||
err = register_netdev (dev);
|
err = register_netdev (dev);
|
||||||
if (err)
|
if (err)
|
||||||
goto err_out_res;
|
goto err_out_free_tx_buf;
|
||||||
|
|
||||||
netdev_info(dev, "ULi M%04lx at pci%s, %pM, irq %d\n",
|
netdev_info(dev, "ULi M%04lx at pci%s, %pM, irq %d\n",
|
||||||
ent->driver_data >> 16, pci_name(pdev),
|
ent->driver_data >> 16, pci_name(pdev),
|
||||||
|
@ -397,16 +394,14 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_out_res:
|
err_out_free_tx_buf:
|
||||||
|
pci_free_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4,
|
||||||
|
db->buf_pool_ptr, db->buf_pool_dma_ptr);
|
||||||
|
err_out_free_tx_desc:
|
||||||
|
pci_free_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20,
|
||||||
|
db->desc_pool_ptr, db->desc_pool_dma_ptr);
|
||||||
|
err_out_release:
|
||||||
pci_release_regions(pdev);
|
pci_release_regions(pdev);
|
||||||
err_out_nomem:
|
|
||||||
if(db->desc_pool_ptr)
|
|
||||||
pci_free_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20,
|
|
||||||
db->desc_pool_ptr, db->desc_pool_dma_ptr);
|
|
||||||
|
|
||||||
if(db->buf_pool_ptr != NULL)
|
|
||||||
pci_free_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4,
|
|
||||||
db->buf_pool_ptr, db->buf_pool_dma_ptr);
|
|
||||||
err_out_disable:
|
err_out_disable:
|
||||||
pci_disable_device(pdev);
|
pci_disable_device(pdev);
|
||||||
err_out_free:
|
err_out_free:
|
||||||
|
@ -422,19 +417,16 @@ static void __devexit uli526x_remove_one (struct pci_dev *pdev)
|
||||||
struct net_device *dev = pci_get_drvdata(pdev);
|
struct net_device *dev = pci_get_drvdata(pdev);
|
||||||
struct uli526x_board_info *db = netdev_priv(dev);
|
struct uli526x_board_info *db = netdev_priv(dev);
|
||||||
|
|
||||||
ULI526X_DBUG(0, "uli526x_remove_one()", 0);
|
unregister_netdev(dev);
|
||||||
|
|
||||||
pci_free_consistent(db->pdev, sizeof(struct tx_desc) *
|
pci_free_consistent(db->pdev, sizeof(struct tx_desc) *
|
||||||
DESC_ALL_CNT + 0x20, db->desc_pool_ptr,
|
DESC_ALL_CNT + 0x20, db->desc_pool_ptr,
|
||||||
db->desc_pool_dma_ptr);
|
db->desc_pool_dma_ptr);
|
||||||
pci_free_consistent(db->pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4,
|
pci_free_consistent(db->pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4,
|
||||||
db->buf_pool_ptr, db->buf_pool_dma_ptr);
|
db->buf_pool_ptr, db->buf_pool_dma_ptr);
|
||||||
unregister_netdev(dev);
|
|
||||||
pci_release_regions(pdev);
|
pci_release_regions(pdev);
|
||||||
free_netdev(dev); /* free board information */
|
|
||||||
pci_set_drvdata(pdev, NULL);
|
|
||||||
pci_disable_device(pdev);
|
pci_disable_device(pdev);
|
||||||
ULI526X_DBUG(0, "uli526x_remove_one() exit", 0);
|
pci_set_drvdata(pdev, NULL);
|
||||||
|
free_netdev(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue