diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2008-10-23 05:01:13 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-10-27 14:49:02 -0400 |
commit | 74d5e8acd95ae934194303138a43b60005fcfad6 (patch) | |
tree | bdc794294ad9915deaf6c8168ec68c730d10924c /drivers/net | |
parent | 2d488c2f514a6c5248a0773c78345626abdc1818 (diff) |
dmfe: check pci_alloc_consistent errors
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>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/tulip/dmfe.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c index 8e46a513a252..c91852f49a48 100644 --- a/drivers/net/tulip/dmfe.c +++ b/drivers/net/tulip/dmfe.c | |||
@@ -420,9 +420,13 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev, | |||
420 | /* Allocate Tx/Rx descriptor memory */ | 420 | /* Allocate Tx/Rx descriptor memory */ |
421 | db->desc_pool_ptr = pci_alloc_consistent(pdev, sizeof(struct tx_desc) * | 421 | db->desc_pool_ptr = pci_alloc_consistent(pdev, sizeof(struct tx_desc) * |
422 | DESC_ALL_CNT + 0x20, &db->desc_pool_dma_ptr); | 422 | DESC_ALL_CNT + 0x20, &db->desc_pool_dma_ptr); |
423 | if (!db->desc_pool_ptr) | ||
424 | goto err_out_res; | ||
423 | 425 | ||
424 | db->buf_pool_ptr = pci_alloc_consistent(pdev, TX_BUF_ALLOC * | 426 | db->buf_pool_ptr = pci_alloc_consistent(pdev, TX_BUF_ALLOC * |
425 | TX_DESC_CNT + 4, &db->buf_pool_dma_ptr); | 427 | TX_DESC_CNT + 4, &db->buf_pool_dma_ptr); |
428 | if (!db->buf_pool_ptr) | ||
429 | goto err_out_free_desc; | ||
426 | 430 | ||
427 | db->first_tx_desc = (struct tx_desc *) db->desc_pool_ptr; | 431 | db->first_tx_desc = (struct tx_desc *) db->desc_pool_ptr; |
428 | db->first_tx_desc_dma = db->desc_pool_dma_ptr; | 432 | db->first_tx_desc_dma = db->desc_pool_dma_ptr; |
@@ -469,7 +473,7 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev, | |||
469 | 473 | ||
470 | err = register_netdev (dev); | 474 | err = register_netdev (dev); |
471 | if (err) | 475 | if (err) |
472 | goto err_out_res; | 476 | goto err_out_free_buf; |
473 | 477 | ||
474 | printk(KERN_INFO "%s: Davicom DM%04lx at pci%s, " | 478 | printk(KERN_INFO "%s: Davicom DM%04lx at pci%s, " |
475 | "%s, irq %d.\n", | 479 | "%s, irq %d.\n", |
@@ -483,6 +487,12 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev, | |||
483 | 487 | ||
484 | return 0; | 488 | return 0; |
485 | 489 | ||
490 | err_out_free_buf: | ||
491 | pci_free_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, | ||
492 | db->buf_pool_ptr, db->buf_pool_dma_ptr); | ||
493 | err_out_free_desc: | ||
494 | pci_free_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, | ||
495 | db->desc_pool_ptr, db->desc_pool_dma_ptr); | ||
486 | err_out_res: | 496 | err_out_res: |
487 | pci_release_regions(pdev); | 497 | pci_release_regions(pdev); |
488 | err_out_disable: | 498 | err_out_disable: |