During pci_scan_one() for devices that were already registered
the pci_common_set() is called to set some of the fields again.
This resulted in bus_info allocation leaking, so this patch
ensures they are always freed beforehand.

Fixes: 8f4de2dba9b9 ("bus/pci: fill bus specific information")

Signed-off-by: Tomasz Zawadzki <tomasz.zawad...@intel.com>
---
 drivers/bus/pci/pci_common.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index 9901c34f4e..9a866055e8 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -114,6 +114,7 @@ pci_common_set(struct rte_pci_device *dev)
                /* Otherwise, it uses the internal, canonical form. */
                dev->device.name = dev->name;
 
+       free(dev->bus_info);
        if (asprintf(&dev->bus_info, "vendor_id=%"PRIx16", device_id=%"PRIx16,
                        dev->id.vendor_id, dev->id.device_id) != -1)
                dev->device.bus_info = dev->bus_info;
-- 
2.38.1

Reply via email to