Skip to contentSkip to conversation

tc35815: fix iomap leak

PATCH Applied Kulikov Vasiliy 3 participants 4 messages Jul 10, 2010 – Jul 13, 2010

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

PATCH 1/1 tc35815: fix iomap leak

If tc35815_init_one() fails we must unmap mapped regions.

---
 drivers/net/tc35815.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/net/tc35815.c +3 -1
index be08b75..99afa5c 100644
@@ -854,7 +854,7 @@ static int __devinit tc35815_init_one(struct pci_dev *pdev,
 
 	rc = register_netdev(dev);
 	if (rc)
-		goto err_out;
+		goto err_out_iounmap;
 
 	memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
 	printk(KERN_INFO "%s: %s at 0x%lx, %pM, IRQ %d\n",
@@ -872,6 +872,8 @@ static int __devinit tc35815_init_one(struct pci_dev *pdev,
 
 err_out_unregister:
 	unregister_netdev(dev);
+err_out_iounmap:
+	pcim_iounmap_regions(pdev, 1 << 1);
 err_out:
 	free_netdev(dev);
 	return rc;
Signature · 1 line
1.7.0.4
#2 lore raw
In reply to Kulikov Vasiliy
Quoted 6 lines · Kulikov Vasiliy

If tc35815_init_one() fails we must unmap mapped regions.

---
 drivers/net/tc35815.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

No, pcim_xxx APIs are _managed_ interfaces. These resources are released automatically. Actually currently nobody in kernel call pcim_iounmap_regions() now.

And _if_ there is any reason to call pcim_iounmap_regions() explicitly, it should be called in tc35815_remove_one() too.

So, NAK.

---
Atsushi Nemoto

maintainer
#3 lore raw

From: Atsushi Nemoto <[email protected]>
Date: Tue, 13 Jul 2010 22:14:28 +0900 (JST)

Quoted 8 lines · Kulikov Vasiliy
Quoted 6 lines

If tc35815_init_one() fails we must unmap mapped regions.

---
 drivers/net/tc35815.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
Quoted 8 lines

No, pcim_xxx APIs are _managed_ interfaces. These resources are released automatically. Actually currently nobody in kernel call pcim_iounmap_regions() now.

And _if_ there is any reason to call pcim_iounmap_regions() explicitly, it should be called in tc35815_remove_one() too.

So, NAK.

I've reverted this patch, thanks.

Can someone go over the other similar patches I applied already to net-next-2.6 to see if they have the same problem? If so I'll revert them too.

BTW, I think from one perspective the pcim_*() APIs make it harder to audit a driver because resource management is magic and implicit rather than explicit. It adds an extra step to the audit, and I don't see any effort being made to do a mass conversion of all drivers to pcim_xxx which would be the only way in my mind for this to truly make it easier to audit drivers for resource leak problems.

If both driver types (pcim_xxx and non-pcim_xxx) exist, it just means more work for auditors as they have oen more thing to check for instead of less things.