From: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
To: Bruce Richardson <bruce.richardson@intel.com>,
David Marchand <david.marchand@redhat.com>
Cc: dev@dpdk.org, Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Subject: [PATCH] bus/pci: fix bus info memleak during PCI scan
Date: Fri, 18 Nov 2022 14:35:47 +0100 [thread overview]
Message-ID: <20221118133547.1203417-1-tomasz.zawadzki@intel.com> (raw)
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.zawadzki@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
next reply other threads:[~2022-11-18 13:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-18 13:35 Tomasz Zawadzki [this message]
2022-11-21 8:44 ` David Marchand
2022-11-22 9:30 ` David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221118133547.1203417-1-tomasz.zawadzki@intel.com \
--to=tomasz.zawadzki@intel.com \
--cc=bruce.richardson@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).