bus/pci: fix leak for unbound devices

Message ID 20210616065257.16044-1-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series bus/pci: fix leak for unbound devices |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Functional success Functional Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot success github build: passed
ci/intel-Testing success Testing PASS
ci/iol-abi-testing warning Testing issues
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Functional fail Functional Testing issues

Commit Message

David Marchand June 16, 2021, 6:52 a.m. UTC
  For devices not bound to any Linux kernel module, we leak a pci object
since it is never added to the PCI bus device list.

Fixes: c79a1c67465d ("bus/pci: optimize bus scan")
Cc: stable@dpdk.org

Reported-by: Owen Hilyard <ohilyard@iol.unh.edu>
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/bus/pci/linux/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

David Marchand July 5, 2021, 9:18 a.m. UTC | #1
On Wed, Jun 16, 2021 at 8:53 AM David Marchand
<david.marchand@redhat.com> wrote:
>
> For devices not bound to any Linux kernel module, we leak a pci object
> since it is never added to the PCI bus device list.
>
> Fixes: c79a1c67465d ("bus/pci: optimize bus scan")
> Cc: stable@dpdk.org
>
> Reported-by: Owen Hilyard <ohilyard@iol.unh.edu>
> Signed-off-by: David Marchand <david.marchand@redhat.com>

No objection?
There is no dedicated maintainer, I'll merge this then.
  
David Marchand July 6, 2021, 11:16 a.m. UTC | #2
On Wed, Jun 16, 2021 at 8:53 AM David Marchand
<david.marchand@redhat.com> wrote:
>
> For devices not bound to any Linux kernel module, we leak a pci object
> since it is never added to the PCI bus device list.
>
> Fixes: c79a1c67465d ("bus/pci: optimize bus scan")
> Cc: stable@dpdk.org
>
> Reported-by: Owen Hilyard <ohilyard@iol.unh.edu>
> Signed-off-by: David Marchand <david.marchand@redhat.com>

Applied.
  

Patch

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