diff options
author | Francois Romieu <romieu@fr.zoreil.com> | 2012-03-10 05:15:15 -0500 |
---|---|---|
committer | Francois Romieu <romieu@fr.zoreil.com> | 2012-04-07 05:47:15 -0400 |
commit | 5e58deb917bfa8dad71cb2e2b9f9572746ff8e6a (patch) | |
tree | ec6ce71b8d42074d22a25caa61b12dd9191433b5 /drivers/net/ethernet/dec | |
parent | 7deb1182175ee06cfcea40452d4f2fb1e33fcbb8 (diff) |
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>
Diffstat (limited to 'drivers/net/ethernet/dec')
-rw-r--r-- | drivers/net/ethernet/dec/tulip/uli526x.c | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/drivers/net/ethernet/dec/tulip/uli526x.c b/drivers/net/ethernet/dec/tulip/uli526x.c index fc4001f6a5e4..c9b33961826c 100644 --- a/drivers/net/ethernet/dec/tulip/uli526x.c +++ b/drivers/net/ethernet/dec/tulip/uli526x.c | |||
@@ -313,9 +313,9 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev, | |||
313 | goto err_out_disable; | 313 | goto err_out_disable; |
314 | } | 314 | } |
315 | 315 | ||
316 | if (pci_request_regions(pdev, DRV_NAME)) { | 316 | err = pci_request_regions(pdev, DRV_NAME); |
317 | if (err < 0) { | ||
317 | pr_err("Failed to request PCI regions\n"); | 318 | pr_err("Failed to request PCI regions\n"); |
318 | err = -ENODEV; | ||
319 | goto err_out_disable; | 319 | goto err_out_disable; |
320 | } | 320 | } |
321 | 321 | ||
@@ -323,18 +323,15 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev, | |||
323 | db = netdev_priv(dev); | 323 | db = netdev_priv(dev); |
324 | 324 | ||
325 | /* Allocate Tx/Rx descriptor memory */ | 325 | /* Allocate Tx/Rx descriptor memory */ |
326 | err = -ENOMEM; | ||
327 | |||
326 | db->desc_pool_ptr = pci_alloc_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, &db->desc_pool_dma_ptr); | 328 | db->desc_pool_ptr = pci_alloc_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, &db->desc_pool_dma_ptr); |
327 | if(db->desc_pool_ptr == NULL) | 329 | if (!db->desc_pool_ptr) |
328 | { | 330 | goto err_out_release; |
329 | err = -ENOMEM; | 331 | |
330 | goto err_out_nomem; | ||
331 | } | ||
332 | db->buf_pool_ptr = pci_alloc_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, &db->buf_pool_dma_ptr); | 332 | db->buf_pool_ptr = pci_alloc_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, &db->buf_pool_dma_ptr); |
333 | if(db->buf_pool_ptr == NULL) | 333 | if (!db->buf_pool_ptr) |
334 | { | 334 | goto err_out_free_tx_desc; |
335 | err = -ENOMEM; | ||
336 | goto err_out_nomem; | ||
337 | } | ||
338 | 335 | ||
339 | db->first_tx_desc = (struct tx_desc *) db->desc_pool_ptr; | 336 | db->first_tx_desc = (struct tx_desc *) db->desc_pool_ptr; |
340 | db->first_tx_desc_dma = db->desc_pool_dma_ptr; | 337 | db->first_tx_desc_dma = db->desc_pool_dma_ptr; |
@@ -387,7 +384,7 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev, | |||
387 | } | 384 | } |
388 | err = register_netdev (dev); | 385 | err = register_netdev (dev); |
389 | if (err) | 386 | if (err) |
390 | goto err_out_res; | 387 | goto err_out_free_tx_buf; |
391 | 388 | ||
392 | netdev_info(dev, "ULi M%04lx at pci%s, %pM, irq %d\n", | 389 | netdev_info(dev, "ULi M%04lx at pci%s, %pM, irq %d\n", |
393 | ent->driver_data >> 16, pci_name(pdev), | 390 | ent->driver_data >> 16, pci_name(pdev), |
@@ -397,16 +394,14 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev, | |||
397 | 394 | ||
398 | return 0; | 395 | return 0; |
399 | 396 | ||
400 | err_out_res: | 397 | err_out_free_tx_buf: |
398 | pci_free_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, | ||
399 | db->buf_pool_ptr, db->buf_pool_dma_ptr); | ||
400 | err_out_free_tx_desc: | ||
401 | pci_free_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, | ||
402 | db->desc_pool_ptr, db->desc_pool_dma_ptr); | ||
403 | err_out_release: | ||
401 | pci_release_regions(pdev); | 404 | pci_release_regions(pdev); |
402 | err_out_nomem: | ||
403 | if(db->desc_pool_ptr) | ||
404 | pci_free_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, | ||
405 | db->desc_pool_ptr, db->desc_pool_dma_ptr); | ||
406 | |||
407 | if(db->buf_pool_ptr != NULL) | ||
408 | pci_free_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, | ||
409 | db->buf_pool_ptr, db->buf_pool_dma_ptr); | ||
410 | err_out_disable: | 405 | err_out_disable: |
411 | pci_disable_device(pdev); | 406 | pci_disable_device(pdev); |
412 | err_out_free: | 407 | err_out_free: |
@@ -422,19 +417,16 @@ static void __devexit uli526x_remove_one (struct pci_dev *pdev) | |||
422 | struct net_device *dev = pci_get_drvdata(pdev); | 417 | struct net_device *dev = pci_get_drvdata(pdev); |
423 | struct uli526x_board_info *db = netdev_priv(dev); | 418 | struct uli526x_board_info *db = netdev_priv(dev); |
424 | 419 | ||
425 | ULI526X_DBUG(0, "uli526x_remove_one()", 0); | 420 | unregister_netdev(dev); |
426 | |||
427 | pci_free_consistent(db->pdev, sizeof(struct tx_desc) * | 421 | pci_free_consistent(db->pdev, sizeof(struct tx_desc) * |
428 | DESC_ALL_CNT + 0x20, db->desc_pool_ptr, | 422 | DESC_ALL_CNT + 0x20, db->desc_pool_ptr, |
429 | db->desc_pool_dma_ptr); | 423 | db->desc_pool_dma_ptr); |
430 | pci_free_consistent(db->pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, | 424 | pci_free_consistent(db->pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, |
431 | db->buf_pool_ptr, db->buf_pool_dma_ptr); | 425 | db->buf_pool_ptr, db->buf_pool_dma_ptr); |
432 | unregister_netdev(dev); | ||
433 | pci_release_regions(pdev); | 426 | pci_release_regions(pdev); |
434 | free_netdev(dev); /* free board information */ | ||
435 | pci_set_drvdata(pdev, NULL); | ||
436 | pci_disable_device(pdev); | 427 | pci_disable_device(pdev); |
437 | ULI526X_DBUG(0, "uli526x_remove_one() exit", 0); | 428 | pci_set_drvdata(pdev, NULL); |
429 | free_netdev(dev); | ||
438 | } | 430 | } |
439 | 431 | ||
440 | 432 | ||