Skip to contentSkip to conversation

xen: fix memory leak in __xen_pcibk_add_pci_dev()

PATCH Applied Daeseok Youn 3 participants 4 messages Apr 1, 2014 – Apr 3, 2014 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xen: fix memory leak in __xen_pcibk_add_pci_dev()

It need to free dev_entry when it failed to assign to a new slot on the virtual PCI bus.

smatch says:
drivers/xen/xen-pciback/vpci.c:142 __xen_pcibk_add_pci_dev() warn:
possible memory leak of 'dev_entry'

---
v2: The kfree() invocation is moved outside the locked region.

 drivers/xen/xen-pciback/vpci.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/xen/xen-pciback/vpci.c +2 -0
index 3165ce3..51afff9 100644
@@ -137,6 +137,8 @@ unlock:
 	/* Publish this device. */
 	if (!err)
 		err = publish_cb(pdev, 0, 0, PCI_DEVFN(slot, func), devid);
+	else
+		kfree(dev_entry);
 
 out:
 	return err;
Signature · 1 line
1.7.4.4
Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 01.04.14 at 12:15, <[email protected]> wrote:

It need to free dev_entry when it failed to assign to a new slot on the virtual PCI bus.

smatch says:
drivers/xen/xen-pciback/vpci.c:142 __xen_pcibk_add_pci_dev() warn:
possible memory leak of 'dev_entry'

As before

Quoted 21 lines

---
v2: The kfree() invocation is moved outside the locked region.

 drivers/xen/xen-pciback/vpci.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/xen/xen-pciback/vpci.c +2 -0
index 3165ce3..51afff9 100644
@@ -137,6 +137,8 @@ unlock:
 	/* Publish this device. */
 	if (!err)
 		err = publish_cb(pdev, 0, 0, PCI_DEVFN(slot, func), devid);
+	else
+		kfree(dev_entry);
 
 out:
 	return err;
Signature · 1 line
1.7.4.4
Reviewed-by on v2 1/1
#2 lore raw
In reply to Daeseok Youn
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 01.04.14 at 12:15, <[email protected]> wrote:

It need to free dev_entry when it failed to assign to a new slot on the virtual PCI bus.

smatch says:
drivers/xen/xen-pciback/vpci.c:142 __xen_pcibk_add_pci_dev() warn:
possible memory leak of 'dev_entry'

As before

Quoted 21 lines

---
v2: The kfree() invocation is moved outside the locked region.

 drivers/xen/xen-pciback/vpci.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/xen/xen-pciback/vpci.c +2 -0
index 3165ce3..51afff9 100644
@@ -137,6 +137,8 @@ unlock:
 	/* Publish this device. */
 	if (!err)
 		err = publish_cb(pdev, 0, 0, PCI_DEVFN(slot, func), devid);
+	else
+		kfree(dev_entry);
 
 out:
 	return err;
Signature · 1 line
1.7.4.4
Applied
#3 lore raw
In reply to Daeseok Youn
Quoted 7 lines · Daeseok Youn

It need to free dev_entry when it failed to assign to a new slot on the virtual PCI bus.

smatch says:
drivers/xen/xen-pciback/vpci.c:142 __xen_pcibk_add_pci_dev() warn:
possible memory leak of 'dev_entry'

Applied to devel/for-linus-3.15.

Thanks.

David