[1/1] bus/fslmc: fix memory leak in secondary process

Message ID c953585f981d443a42b24e284a48eed8a8450009.1594270224.git.wangyunjian@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series [1/1] bus/fslmc: fix memory leak in secondary process |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-intel-Performance success Performance Testing PASS

Commit Message

Yunjian Wang July 9, 2020, 10:39 a.m. UTC
  From: Yunjian Wang <wangyunjian@huawei.com>

In fslmc_process_mcp(), we allocate memory for 'dev_name' but not released
before return in secondary process.

Coverity issue: 268327
Fixes: e55d0494ab98 ("bus/fslmc: support secondary process")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/bus/fslmc/fslmc_vfio.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Hemant Agrawal July 9, 2020, 3:15 p.m. UTC | #1
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
  
David Marchand July 17, 2020, 9:20 a.m. UTC | #2
On Thu, Jul 9, 2020 at 12:40 PM wangyunjian <wangyunjian@huawei.com> wrote:
>
> From: Yunjian Wang <wangyunjian@huawei.com>
>
> In fslmc_process_mcp(), we allocate memory for 'dev_name' but not released
> before return in secondary process.

dev_name is not used anymore since a69f79300262 ("bus/fslmc: support
multi VFIO group")
We can remove it entirely in this function.
  
Yunjian Wang July 17, 2020, 9:36 a.m. UTC | #3
> -----Original Message-----
> From: David Marchand [mailto:david.marchand@redhat.com]
> Sent: Friday, July 17, 2020 5:21 PM
> To: wangyunjian <wangyunjian@huawei.com>; Hemant Agrawal
> <hemant.agrawal@nxp.com>
> Cc: dev <dev@dpdk.org>; Sachin Saxena <sachin.saxena@nxp.com>; Lilijun
> (Jerry) <jerry.lilijun@huawei.com>; xudingke <xudingke@huawei.com>; dpdk
> stable <stable@dpdk.org>
> Subject: Re: [dpdk-dev] [PATCH 1/1] bus/fslmc: fix memory leak in secondary
> process
> 
> On Thu, Jul 9, 2020 at 12:40 PM wangyunjian <wangyunjian@huawei.com>
> wrote:
> >
> > From: Yunjian Wang <wangyunjian@huawei.com>
> >
> > In fslmc_process_mcp(), we allocate memory for 'dev_name' but not
> > released before return in secondary process.
> 
> dev_name is not used anymore since a69f79300262 ("bus/fslmc: support multi
> VFIO group") We can remove it entirely in this function.

Thanks for your suggestion, will include it in next version.

Yunjian

> 
> --
> David Marchand
  

Patch

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index efe2c43d3..247a265c0 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -772,6 +772,7 @@  fslmc_process_mcp(struct rte_dpaa2_device *dev)
 	 */
 	if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
 		rte_mcp_ptr_list[MC_PORTAL_INDEX] = (void *)v_addr;
+		free(dev_name);
 		return 0;
 	}