net/thunderx: fix memory leak when allocate rbdr desc ring fails
diff mbox series

Message ID 6d9af419c1c9eeac76f59b7484471e69c4fa43a6.1603172717.git.wangyunjian@huawei.com
State Accepted
Delegated to: Jerin Jacob
Headers show
Series
  • net/thunderx: fix memory leak when allocate rbdr desc ring fails
Related show

Checks

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

Commit Message

wangyunjian Oct. 20, 2020, 3:02 p.m. UTC
From: Yunjian Wang <wangyunjian@huawei.com>

In nicvf_qset_rbdr_alloc(), we allocate memory for the 'rbdr'
structure but not released when allocate 'rbdr desc ring' fails.

Fixes: 7413feee662d ("net/thunderx: add device start/stop and close")
Cc: stable@dpdk.org

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

Comments

Jerin Jacob Oct. 31, 2020, 1:18 p.m. UTC | #1
On Tue, Oct 20, 2020 at 8:33 PM wangyunjian <wangyunjian@huawei.com> wrote:
>
> From: Yunjian Wang <wangyunjian@huawei.com>
>
> In nicvf_qset_rbdr_alloc(), we allocate memory for the 'rbdr'
> structure but not released when allocate 'rbdr desc ring' fails.
>
> Fixes: 7413feee662d ("net/thunderx: add device start/stop and close")
> Cc: stable@dpdk.org
>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>


Acked-by: Jerin Jacob <jerinj@marvell.com>
Applied to dpdk-next-net-mrvl/for-main. Thanks

> ---
>  drivers/net/thunderx/nicvf_ethdev.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
> index f0bd20a22b..b6bb05e500 100644
> --- a/drivers/net/thunderx/nicvf_ethdev.c
> +++ b/drivers/net/thunderx/nicvf_ethdev.c
> @@ -638,6 +638,7 @@ nicvf_qset_rbdr_alloc(struct rte_eth_dev *dev, struct nicvf *nic,
>                                       NICVF_RBDR_BASE_ALIGN_BYTES, nic->node);
>         if (rz == NULL) {
>                 PMD_INIT_LOG(ERR, "Failed to allocate mem for rbdr desc ring");
> +               rte_free(rbdr);
>                 return -ENOMEM;
>         }
>
> --
> 2.23.0
>

Patch
diff mbox series

diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
index f0bd20a22b..b6bb05e500 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -638,6 +638,7 @@  nicvf_qset_rbdr_alloc(struct rte_eth_dev *dev, struct nicvf *nic,
 				      NICVF_RBDR_BASE_ALIGN_BYTES, nic->node);
 	if (rz == NULL) {
 		PMD_INIT_LOG(ERR, "Failed to allocate mem for rbdr desc ring");
+		rte_free(rbdr);
 		return -ENOMEM;
 	}