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>
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;
/* skip non-network devices */
if (rte_uuid_compare(dev->class_id, vmbus_nic_uuid) != 0) {
+ free(dev_name);
free(dev);
return 0;
}
} else { /* already registered */
VMBUS_LOG(NOTICE,
"%s already registered", name);
+ free(dev_name);
free(dev);
}
return 0;
error:
VMBUS_LOG(DEBUG, "failed");
+ free(dev_name);
free(dev);
return -1;
}