bus/vmbus: fix leak on device scan
Caught running ASAN. The device name was leaked on scan. rte_device name field being a const, use a local pointer and release in error path. Fixes: 831dba47bd36 ("bus/vmbus: add Hyper-V virtual bus support") Cc: stable@dpdk.org Signed-off-by: David Marchand <david.marchand@redhat.com> Acked-by: Long Li <longli@microsoft.com>
This commit is contained in:
parent
ddfc59f4fb
commit
c6c865d7e2
@ -236,13 +236,14 @@ vmbus_scan_one(const char *name)
|
||||
char filename[PATH_MAX];
|
||||
char dirname[PATH_MAX];
|
||||
unsigned long tmp;
|
||||
char *dev_name;
|
||||
|
||||
dev = calloc(1, sizeof(*dev));
|
||||
if (dev == NULL)
|
||||
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 +262,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 +314,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 +325,7 @@ vmbus_scan_one(const char *name)
|
||||
error:
|
||||
VMBUS_LOG(DEBUG, "failed");
|
||||
|
||||
free(dev_name);
|
||||
free(dev);
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user