mem: fix mem leak issue when attaching a PCI device without driver to DPDK

Message ID 20210628090249.70873-1-winsome8282@163.com (mailing list archive)
State Rejected, archived
Delegated to: David Marchand
Headers
Series mem: fix mem leak issue when attaching a PCI device without driver to DPDK |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

RickZhong June 28, 2021, 9:02 a.m. UTC
  when trying to attach a PCI device without driver to DPDK,
the 'dev' is malloced but not freed.

Signed-off-by: RickZhong <winsome8282@163.com>
---
 drivers/bus/pci/linux/pci.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

David Marchand June 28, 2021, 9:25 a.m. UTC | #1
On Mon, Jun 28, 2021 at 11:03 AM RickZhong <winsome8282@163.com> wrote:
>
> when trying to attach a PCI device without driver to DPDK,
> the 'dev' is malloced but not freed.
>
> Signed-off-by: RickZhong <winsome8282@163.com>

Thanks for the patch.

I already submitted a similar fix.
https://patchwork.dpdk.org/project/dpdk/patch/20210616065257.16044-1-david.marchand@redhat.com/
  

Patch

diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index 0dc99e9cb..909502ecc 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -332,6 +332,7 @@  pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
 			dev->kdrv = RTE_PCI_KDRV_UNKNOWN;
 	} else {
 		dev->kdrv = RTE_PCI_KDRV_NONE;
+		free(dev);
 		return 0;
 	}
 	/* device is valid, add in list (sorted) */