bus/fslmc: fix memory leak in secondary process
authorYunjian Wang <wangyunjian@huawei.com>
Fri, 17 Jul 2020 10:50:17 +0000 (18:50 +0800)
committerDavid Marchand <david.marchand@redhat.com>
Tue, 21 Jul 2020 18:48:57 +0000 (20:48 +0200)
In fslmc_process_mcp(), we allocate memory for 'dev_name' but not
released before return in secondary process. And it is not used
since commit a69f79300262 ("bus/fslmc: support multi VFIO group"),
so it can be removed.

Fixes: e55d0494ab98 ("bus/fslmc: support secondary process")
Cc: stable@dpdk.org
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
drivers/bus/fslmc/fslmc_vfio.c

index efe2c43..9134ec5 100644 (file)
@@ -739,7 +739,6 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev)
 {
        int ret;
        intptr_t v_addr;
-       char *dev_name = NULL;
        struct fsl_mc_io dpmng  = {0};
        struct mc_version mc_ver_info = {0};
 
@@ -750,13 +749,6 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev)
                goto cleanup;
        }
 
-       dev_name = strdup(dev->device.name);
-       if (!dev_name) {
-               DPAA2_BUS_ERR("Unable to allocate MC device name memory");
-               ret = -ENOMEM;
-               goto cleanup;
-       }
-
        v_addr = vfio_map_mcp_obj(dev->device.name);
        if (v_addr == (intptr_t)MAP_FAILED) {
                DPAA2_BUS_ERR("Error mapping region (errno = %d)", errno);
@@ -793,13 +785,9 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev)
        }
        rte_mcp_ptr_list[MC_PORTAL_INDEX] = (void *)v_addr;
 
-       free(dev_name);
        return 0;
 
 cleanup:
-       if (dev_name)
-               free(dev_name);
-
        if (rte_mcp_ptr_list) {
                free(rte_mcp_ptr_list);
                rte_mcp_ptr_list = NULL;