diff mbox

PCI, IOV: fix a resource leakage on error recovery path

Message ID 1369888293-13387-1-git-send-email-jiang.liu@huawei.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Jiang Liu May 30, 2013, 4:31 a.m. UTC
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
---
Hi Bjorn,
	Could you please help to apply this small patch onto the
jiang-bus-lock-v3, which addresses a memory leakage issue pointed
out by Yinghai? Or you may fold it into " PCI, IOV: simplify IOV 
implementation".
Thanks!
Gerry
---
 drivers/pci/iov.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 5eb8165..458fb39 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -122,8 +122,9 @@  failed1:
 	pci_dev_put(dev);
 	mutex_lock(&iov->dev->sriov->lock);
 	pci_stop_and_remove_bus_device(virtfn);
-	virtfn_remove_bus(dev->bus, bus);
 failed0:
+	if (bus)
+		virtfn_remove_bus(dev->bus, bus);
 	mutex_unlock(&iov->dev->sriov->lock);
 
 	return rc;