DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: aconole@redhat.com, zhihongx.peng@intel.com, stable@dpdk.org,
	Stephen Hemminger <sthemmin@microsoft.com>,
	Long Li <longli@microsoft.com>
Subject: [dpdk-dev] [PATCH 1/3] bus/vmbus: fix leak on device scan
Date: Fri, 17 Sep 2021 10:23:11 +0200	[thread overview]
Message-ID: <20210917082313.21934-2-david.marchand@redhat.com> (raw)
In-Reply-To: <20210917082313.21934-1-david.marchand@redhat.com>

Caught running ASAN.

The device name is leaked on scan.
rte_device name field being a const, use the private vmbus struct to
store the device name and point at it.

Fixes: 831dba47bd36 ("bus/vmbus: add Hyper-V virtual bus support")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/bus/vmbus/linux/vmbus_bus.c | 5 ++++-
 drivers/bus/vmbus/rte_bus_vmbus.h   | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/vmbus/linux/vmbus_bus.c b/drivers/bus/vmbus/linux/vmbus_bus.c
index 3c924eee14..d8eb07d398 100644
--- a/drivers/bus/vmbus/linux/vmbus_bus.c
+++ b/drivers/bus/vmbus/linux/vmbus_bus.c
@@ -242,7 +242,7 @@ vmbus_scan_one(const char *name)
 		return -1;
 
 	dev->device.bus = &rte_vmbus_bus.bus;
-	dev->device.name = strdup(name);
+	dev->device.name = dev->name = strdup(name);
 	if (!dev->device.name)
 		goto error;
 
@@ -261,6 +261,7 @@ vmbus_scan_one(const char *name)
 
 	/* skip non-network devices */
 	if (rte_uuid_compare(dev->class_id, vmbus_nic_uuid) != 0) {
+		free(dev->name);
 		free(dev);
 		return 0;
 	}
@@ -312,6 +313,7 @@ vmbus_scan_one(const char *name)
 		} else { /* already registered */
 			VMBUS_LOG(NOTICE,
 				"%s already registered", name);
+			free(dev->name);
 			free(dev);
 		}
 		return 0;
@@ -322,6 +324,7 @@ vmbus_scan_one(const char *name)
 error:
 	VMBUS_LOG(DEBUG, "failed");
 
+	free(dev->name);
 	free(dev);
 	return -1;
 }
diff --git a/drivers/bus/vmbus/rte_bus_vmbus.h b/drivers/bus/vmbus/rte_bus_vmbus.h
index 4cf73ce815..438eb481fc 100644
--- a/drivers/bus/vmbus/rte_bus_vmbus.h
+++ b/drivers/bus/vmbus/rte_bus_vmbus.h
@@ -65,6 +65,7 @@ struct rte_vmbus_device {
 	TAILQ_ENTRY(rte_vmbus_device) next;    /**< Next probed VMBUS device */
 	const struct rte_vmbus_driver *driver; /**< Associated driver */
 	struct rte_device device;              /**< Inherit core device */
+	char *name;                            /**< Device name */
 	rte_uuid_t device_id;		       /**< VMBUS device id */
 	rte_uuid_t class_id;		       /**< VMBUS device type */
 	uint32_t relid;			       /**< id for primary */
-- 
2.23.0


  reply	other threads:[~2021-09-17  8:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-17  8:23 [dpdk-dev] [PATCH 0/3] Experiment ASAN in GHA David Marchand
2021-09-17  8:23 ` David Marchand [this message]
2021-09-29 20:57   ` [dpdk-dev] [PATCH 1/3] bus/vmbus: fix leak on device scan Long Li
2021-09-30  7:50     ` David Marchand
2021-09-30 19:14       ` Long Li
2021-10-01  6:47         ` David Marchand
2021-10-01 16:28           ` Long Li
2021-09-17  8:23 ` [dpdk-dev] [PATCH 2/3] test/latencystats: fix incorrect loop boundary David Marchand
2021-09-20  8:51   ` Pattan, Reshma
2021-09-17  8:23 ` [dpdk-dev] [PATCH 3/3] ci: run unit tests with ASAN David Marchand
2021-10-02 16:24 ` [dpdk-dev] [PATCH v2 0/3] Experiment ASAN in GHA David Marchand
2021-10-02 16:24   ` [dpdk-dev] [PATCH v2 1/3] bus/vmbus: fix leak on device scan David Marchand
2021-10-04 17:43     ` Long Li
2021-10-02 16:24   ` [dpdk-dev] [PATCH v2 2/3] test/latencystats: fix incorrect loop boundary David Marchand
2021-10-02 16:24   ` [dpdk-dev] [PATCH v2 3/3] ci: run unit tests with ASAN David Marchand
2021-10-05 12:00     ` Aaron Conole
2021-10-05 15:20   ` [dpdk-dev] [PATCH v2 0/3] Experiment ASAN in GHA 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=20210917082313.21934-2-david.marchand@redhat.com \
    --to=david.marchand@redhat.com \
    --cc=aconole@redhat.com \
    --cc=dev@dpdk.org \
    --cc=longli@microsoft.com \
    --cc=stable@dpdk.org \
    --cc=sthemmin@microsoft.com \
    --cc=zhihongx.peng@intel.com \
    /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).