Skip to content

Commit

Permalink
dmfe: check pci_alloc_consistent errors
Browse files Browse the repository at this point in the history
We need to check the address that pci_alloc_consistent() returns since
it might fail.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
  • Loading branch information
FUJITA Tomonori authored and Jeff Garzik committed Oct 27, 2008
1 parent 2d488c2 commit 74d5e8a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion drivers/net/tulip/dmfe.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,13 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
/* Allocate Tx/Rx descriptor memory */
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)
goto err_out_res;

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)
goto err_out_free_desc;

db->first_tx_desc = (struct tx_desc *) db->desc_pool_ptr;
db->first_tx_desc_dma = db->desc_pool_dma_ptr;
Expand Down Expand Up @@ -469,7 +473,7 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,

err = register_netdev (dev);
if (err)
goto err_out_res;
goto err_out_free_buf;

printk(KERN_INFO "%s: Davicom DM%04lx at pci%s, "
"%s, irq %d.\n",
Expand All @@ -483,6 +487,12 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,

return 0;

err_out_free_buf:
pci_free_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4,
db->buf_pool_ptr, db->buf_pool_dma_ptr);
err_out_free_desc:
pci_free_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20,
db->desc_pool_ptr, db->desc_pool_dma_ptr);
err_out_res:
pci_release_regions(pdev);
err_out_disable:
Expand Down

0 comments on commit 74d5e8a

Please sign in to comment.