[dpdk-dev,v3,2/2] net/mlx5: fix resource leak in case of error

Message ID 1525770687-22980-2-git-send-email-rasland@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Shahaf Shuler
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Raslan Darawsheh May 8, 2018, 9:11 a.m. UTC
  If something went wrong in mlx5 pci prop the allocated eth dev
will cause a memory leak.

This commit release the eth dev that was previously allocated.

Fixes: 771fa900b73a ("mlx5: introduce new driver for Mellanox ConnectX-4 adapters")
Cc: stable@dpdk.org

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>

---
v2 changes:
 Reword the commit log.

v3 changes:
 Reword the commit log.
 change the release to be only in primary process.
---
---
 drivers/net/mlx5/mlx5.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Yongseok Koh May 8, 2018, 7:19 p.m. UTC | #1
> On May 8, 2018, at 2:11 AM, Raslan Darawsheh <rasland@mellanox.com> wrote:
> 
> If something went wrong in mlx5 pci prop the allocated eth dev
> will cause a memory leak.
> 
> This commit release the eth dev that was previously allocated.
> 
> Fixes: 771fa900b73a ("mlx5: introduce new driver for Mellanox ConnectX-4 adapters")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> 
> ---
Acked-by: Yongseok Koh <yskoh@mellanox.com>
 
Thanks
  
Shahaf Shuler May 9, 2018, 9:50 a.m. UTC | #2
--Shahaf


> -----Original Message-----
> From: Yongseok Koh
> Sent: Tuesday, May 8, 2018 10:20 PM
> To: Raslan Darawsheh <rasland@mellanox.com>
> Cc: Shahaf Shuler <shahafs@mellanox.com>; dev@dpdk.org; Thomas
> Monjalon <thomas@monjalon.net>; Ophir Munk
> <ophirmu@mellanox.com>; stable@dpdk.org
> Subject: Re: [PATCH v3 2/2] net/mlx5: fix resource leak in case of error
> 
> 
> > On May 8, 2018, at 2:11 AM, Raslan Darawsheh <rasland@mellanox.com>
> wrote:
> >
> > If something went wrong in mlx5 pci prop the allocated eth dev will
> > cause a memory leak.
> >
> > This commit release the eth dev that was previously allocated.

Considering this patch as a temporary w.a. as there is patchset[1] which starts to address this issue from ethdev layer.

> >
> > Fixes: 771fa900b73a ("mlx5: introduce new driver for Mellanox
> > ConnectX-4 adapters")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> >
> > ---
> Acked-by: Yongseok Koh <yskoh@mellanox.com>
> 
> Thanks


[1]
http://dpdk.org/dev/patchwork/patch/39544/
  

Patch

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 3831e3d..c4ab166 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -1063,6 +1063,8 @@  mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			claim_zero(mlx5_glue->dealloc_pd(pd));
 		if (ctx)
 			claim_zero(mlx5_glue->close_device(ctx));
+		if (eth_dev && rte_eal_process_type() == RTE_PROC_PRIMARY)
+			rte_eth_dev_release_port(eth_dev);
 		break;
 	}
 	/*