The device name allocated during scan was never freed.
Store it to the (unused) name field in the rte_dpaa2_device.
This simplifies the device freeing to a simple free() call later.
Fixes: 828d51d8fc3e ("bus/fslmc: refactor scan and probe functions")
Cc: [email protected]
Signed-off-by: David Marchand <[email protected]>
---
drivers/bus/fslmc/bus_fslmc_driver.h | 4 +---
drivers/bus/fslmc/fslmc_bus.c | 8 ++++----
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/bus/fslmc/bus_fslmc_driver.h
b/drivers/bus/fslmc/bus_fslmc_driver.h
index 44f81cf662..ead9d6613c 100644
--- a/drivers/bus/fslmc/bus_fslmc_driver.h
+++ b/drivers/bus/fslmc/bus_fslmc_driver.h
@@ -39,8 +39,6 @@ extern "C" {
struct vfio_device_info;
-#define FSLMC_OBJECT_MAX_LEN 32 /**< Length of each device on bus */
-
#define DPAA2_INVALID_MBUF_SEQN 0
typedef uint32_t dpaa2_seqn_t;
@@ -101,7 +99,7 @@ struct rte_dpaa2_device {
uint16_t ep_object_id; /**< Endpoint DPAA2 Object ID */
char ep_name[RTE_DEV_NAME_MAX_LEN];
struct rte_intr_handle *intr_handle; /**< Interrupt handle */
- char name[FSLMC_OBJECT_MAX_LEN]; /**< DPAA2 Object name*/
+ char name[RTE_DEV_NAME_MAX_LEN];
};
typedef int (*rte_dpaa2_obj_create_t)(int vdev_fd,
diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 94ae96f942..4b0896e42e 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -179,12 +179,12 @@ scan_one_fslmc_device(char *dev_name)
}
sscanf(t_ptr, "%hu", &dev->object_id);
- dev->device.name = strdup(dev_name);
- if (!dev->device.name) {
- DPAA2_BUS_ERR("Unable to clone device name. Out of memory");
- ret = -ENOMEM;
+ if (rte_strscpy(dev->name, dev_name, sizeof(dev->name)) < 0) {
+ DPAA2_BUS_ERR("Unable to copy device name: %s",
rte_strerror(rte_errno));
+ ret = -rte_errno;
goto cleanup;
}
+ dev->device.name = dev->name;
dev->device.devargs = rte_bus_find_devargs(&rte_fslmc_bus, dev_name);
/* Update the device found into the device_count table */
--
2.54.0