From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by dpdk.org (Postfix) with ESMTP id 6222A1B873 for ; Tue, 15 May 2018 15:48:21 +0200 (CEST) Received: by mail-wr0-f196.google.com with SMTP id o4-v6so238536wrm.0 for ; Tue, 15 May 2018 06:48:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SpCnKhe/XGL99SBqEgHIy5h+8Wby+oN5va3M5TIAWxk=; b=Em/mJZ9G42g3xQ3dURY4+SpSHU6RbO59L90CkfO0xkY5CX5q/wpMr096HxsFcDWR5v Ys6lFRd43k783RPYtloW1sjGspgQoutznvn11tlhvRmdZX3xzJoDpH8p8u3CFq56xufc eYdT7e0v3vOKyD102AbliXdUmYMr6pJ+1IAuD9CpUMVFo1zBoXRFS/OP5pOXBz/aCcoI YwBUG3Dr6A+12I6ADtv/q/F5JLd2VVuJja4EoFz+wgnmfzh0xriUxOpqlSbJ4J84e3DB a4vuWr+uepSm3pnlC6zrv5cTpnuOelpnGxnr8SF9PEV85sX9GvyiOY7HkO10NUsSieQQ EHIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SpCnKhe/XGL99SBqEgHIy5h+8Wby+oN5va3M5TIAWxk=; b=Wq4BMFlVo/f5LWMjgPg9GiXdMC6dQW/JX6vUcVfMNjy9wusk9qxWlDCoRPBa4WPG3V o2FOnHu8OotnwGBIWQY+cAGn/WJzTIhx0dit417UKgBLAHFk7J0U9RYdP17uyhkIttLU puhMIF+4gc7LhkzvzGmjywW/FDQxoG66b9eqi6cxj16+1Zt1Gmij+PJ7ZeVv6u2iQXFi FJUrs8BwJa8w0VrdIRK4YbSYsUxbMSMPsL4uigzFqxql3xTpz5xPM37dayQ5yILKjm8H WK9b4wZMzfWs+WuO0Y1TBwPBsWoyhueRtiscbMSjdaCuQQ6fP73Vv/VdRrsd+8hPdwWI Dj+g== X-Gm-Message-State: ALKqPwfLHBJm3YPLK2m0hPYR+qayXtMYUToXH4rRGSGaKZjvjR+T4r+g k6VAVzA+U0fzGUUgBnR64FE= X-Google-Smtp-Source: AB8JxZpPz+23gn7ZKOyzElpNXK96kgRegPEc49g3H/VeGNw/i6SYv2rz+63ebI766uo2/6MXeAZkww== X-Received: by 2002:adf:8505:: with SMTP id 5-v6mr10193083wrh.77.1526392101073; Tue, 15 May 2018 06:48:21 -0700 (PDT) Received: from localhost (slip139-92-244-193.lon.uk.prserv.net. [139.92.244.193]) by smtp.gmail.com with ESMTPSA id f6-v6sm104601wrj.66.2018.05.15.06.48.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 May 2018 06:48:20 -0700 (PDT) From: luca.boccassi@gmail.com To: Shreyansh Jain Cc: Hemant Agrawal , dpdk stable Date: Tue, 15 May 2018 14:46:34 +0100 Message-Id: <20180515134731.9337-23-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180515134731.9337-1-luca.boccassi@gmail.com> References: <20180503110612.12146-2-luca.boccassi@gmail.com> <20180515134731.9337-1-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'bus/fslmc: fix memory leak and cleanup' has been queued to stable release 18.02.2 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 May 2018 13:48:21 -0000 Hi, FYI, your patch has been queued to stable release 18.02.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/16/18. So please shout if anyone has objections. Thanks. Luca Boccassi --- >>From da3d251a96eccbdfecb39f1b8eebc465518b76e0 Mon Sep 17 00:00:00 2001 From: Shreyansh Jain Date: Wed, 9 May 2018 20:57:51 +0530 Subject: [PATCH] bus/fslmc: fix memory leak and cleanup [ upstream commit 58b7c9ceed1efced68d4fc7106915fab3b467e47 ] Coverity issue: 268327 Fixes: 828d51d8fc3e ("bus/fslmc: refactor scan and probe functions") Signed-off-by: Shreyansh Jain Acked-by: Hemant Agrawal --- drivers/bus/fslmc/fslmc_vfio.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index affc9f80e..f62acb38b 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -466,38 +466,41 @@ fslmc_process_iodevices(struct rte_dpaa2_device *dev) static int fslmc_process_mcp(struct rte_dpaa2_device *dev) { + int ret; int64_t v_addr; - char *dev_name; + char *dev_name = NULL; struct fsl_mc_io dpmng = {0}; struct mc_version mc_ver_info = {0}; rte_mcp_ptr_list = malloc(sizeof(void *) * 1); if (!rte_mcp_ptr_list) { FSLMC_VFIO_LOG(ERR, "Out of memory"); - return -ENOMEM; + ret = -ENOMEM; + goto cleanup; } dev_name = strdup(dev->device.name); if (!dev_name) { FSLMC_VFIO_LOG(ERR, "Out of memory."); - free(rte_mcp_ptr_list); - rte_mcp_ptr_list = NULL; - return -ENOMEM; + ret = -ENOMEM; + goto cleanup; } v_addr = vfio_map_mcp_obj(&vfio_group, dev_name); if (v_addr == (int64_t)MAP_FAILED) { FSLMC_VFIO_LOG(ERR, "Error mapping region (errno = %d)", errno); - free(rte_mcp_ptr_list); - rte_mcp_ptr_list = NULL; - return -1; + ret = -1; + goto cleanup; } /* check the MC version compatibility */ dpmng.regs = (void *)v_addr; - if (mc_get_version(&dpmng, CMD_PRI_LOW, &mc_ver_info)) + if (mc_get_version(&dpmng, CMD_PRI_LOW, &mc_ver_info)) { RTE_LOG(WARNING, PMD, "\tmc_get_version failed\n"); + ret = -1; + goto cleanup; + } if ((mc_ver_info.major != MC_VER_MAJOR) || (mc_ver_info.minor < MC_VER_MINOR)) { @@ -506,13 +509,24 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev) MC_VER_MAJOR, MC_VER_MINOR, mc_ver_info.major, mc_ver_info.minor, mc_ver_info.revision); - free(rte_mcp_ptr_list); - rte_mcp_ptr_list = NULL; - return -1; + ret = -1; + goto cleanup; } rte_mcp_ptr_list[0] = (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; + } + + return ret; } int -- 2.14.2