Skip to contentSkip to conversation

tehuti: possible leak in bdx_probe

PATCH Applied Florin Malita 4 participants 4 messages Oct 13, 2007 – Oct 15, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tehuti: possible leak in bdx_probe

If pci_enable_device fails, bdx_probe returns without freeing the allocated pci_nic structure.

Coverity CID 1908.

---

drivers/net/tehuti.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/tehuti.c +0 -0
index 8d04654..4e1b84e 100644
@@ -1906,7 +1906,7 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
    /************** pci *****************/

if ((err = pci_enable_device(pdev))) /* it trigers interrupt, dunno why. */
- RET(err); /* it's not a problem though */
+ goto err_pci; /* it's not a problem though */

	if (!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK)) &&
	    !(err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))) {
@@ -2076,6 +2076,7 @@ err_out_res:
	pci_release_regions(pdev);
err_dma:
	pci_disable_device(pdev);
+err_pci:
	vfree(nic);

	RET(err);
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines

-----Original Message-----
From: Florin Malita [mailto:[email protected]]

If pci_enable_device fails, bdx_probe returns without freeing the allocated pci_nic structure.

Coverity CID 1908.

Looks fine to me.

Thanks!

Quoted 15 lines

---

 drivers/net/tehuti.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/tehuti.c +0 -0
index 8d04654..4e1b84e 100644
@@ -1906,7 +1906,7 @@ bdx_probe(struct pci_dev *pdev, const struct
 pci_device_id *ent)
 
     /************** pci *****************/
 	if ((err = pci_enable_device(pdev)))	/* it trigers interrupt,

dunno why. */

drivers/net/tehuti.c

Quoted 1 line
drivers/net/tehuti.c +0 -1
-		RET(err);			/* it's not a problem though

*/

drivers/net/tehuti.c

Quoted 1 line
drivers/net/tehuti.c +1 -0
+		goto err_pci;			/* it's not a problem though

*/

Quoted 11 lines
drivers/net/tehuti.c +1 -0
 	if (!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK)) &&
 	    !(err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))) {
@@ -2076,6 +2076,7 @@ err_out_res:
 	pci_release_regions(pdev);
 err_dma:
 	pci_disable_device(pdev);
+err_pci:
 	vfree(nic);
 
 	RET(err);
Acked-by on v1 1/1
#2 lore raw
In reply to Florin Malita
Quoted 31 lines · Florin Malita

If pci_enable_device fails, bdx_probe returns without freeing the allocated pci_nic structure.

Coverity CID 1908.

---

drivers/net/tehuti.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/tehuti.c +1 -1
index 8d04654..4e1b84e 100644
@@ -1906,7 +1906,7 @@ bdx_probe(struct pci_dev *pdev, const struct 
 pci_device_id *ent)
 
    /************** pci *****************/
 	if ((err = pci_enable_device(pdev)))	/* it trigers interrupt, 
 	dunno why. */
-		RET(err);			/* it's not a problem though 
 */
+		goto err_pci;			/* it's not a problem though 

*/

	if (!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK)) &&
	    !(err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))) {
drivers/net/tehuti.c +0 -0
@@ -2076,6 +2076,7 @@ err_out_res:
 	pci_release_regions(pdev);

err_dma:

Quoted 6 lines
	pci_disable_device(pdev);
+err_pci:
	vfree(nic);

	RET(err);

Good catch. Thanks!