patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] net/mlx4: fix drop queue mem alloc failure handle
@ 2020-05-06 16:27 Michael Baum
  2020-05-11 13:33 ` [dpdk-stable] [dpdk-dev] " Raslan Darawsheh
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Baum @ 2020-05-06 16:27 UTC (permalink / raw)
  To: dev; +Cc: Matan Azrad, Viacheslav Ovsiienko, stable

The function mlx4_drop_get() creates pointer to a struct mlx4_drop and
if needed allocates by rte_malloc.

If the allocation is failed the function goes to label “error”, and
there does dereference to a null pointer.

Skip resources cleaning when the memory allocation is failed.

Coverity issue: 146206
Coverity issue: 146146
Fixes: d3a7e09234e4 ("net/mlx4: allocate drop flow resources on demand")
Cc: stable@dpdk.org

Signed-off-by: Michael Baum <michaelba@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx4/mlx4_flow.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index 793f0b0..2a86382 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -980,12 +980,13 @@ struct mlx4_drop {
 	priv->drop = drop;
 	return drop;
 error:
-	if (drop->qp)
-		claim_zero(mlx4_glue->destroy_qp(drop->qp));
-	if (drop->cq)
-		claim_zero(mlx4_glue->destroy_cq(drop->cq));
-	if (drop)
+	if (drop) {
+		if (drop->qp)
+			claim_zero(mlx4_glue->destroy_qp(drop->qp));
+		if (drop->cq)
+			claim_zero(mlx4_glue->destroy_cq(drop->cq));
 		rte_free(drop);
+	}
 	rte_errno = ENOMEM;
 	return NULL;
 }
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH] net/mlx4: fix drop queue mem alloc failure handle
  2020-05-06 16:27 [dpdk-stable] [PATCH] net/mlx4: fix drop queue mem alloc failure handle Michael Baum
@ 2020-05-11 13:33 ` Raslan Darawsheh
  0 siblings, 0 replies; 2+ messages in thread
From: Raslan Darawsheh @ 2020-05-11 13:33 UTC (permalink / raw)
  To: Michael Baum, dev; +Cc: Matan Azrad, Slava Ovsiienko, stable

Hi,
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Michael Baum
> Sent: Wednesday, May 6, 2020 7:28 PM
> To: dev@dpdk.org
> Cc: Matan Azrad <matan@mellanox.com>; Slava Ovsiienko
> <viacheslavo@mellanox.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] net/mlx4: fix drop queue mem alloc failure
> handle
> 
> The function mlx4_drop_get() creates pointer to a struct mlx4_drop and
> if needed allocates by rte_malloc.
> 
> If the allocation is failed the function goes to label “error”, and
> there does dereference to a null pointer.
> 
> Skip resources cleaning when the memory allocation is failed.
> 
> Coverity issue: 146206
> Coverity issue: 146146
> Fixes: d3a7e09234e4 ("net/mlx4: allocate drop flow resources on demand")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Michael Baum <michaelba@mellanox.com>
> Acked-by: Matan Azrad <matan@mellanox.com>
> ---
>  drivers/net/mlx4/mlx4_flow.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
> index 793f0b0..2a86382 100644
> --- a/drivers/net/mlx4/mlx4_flow.c
> +++ b/drivers/net/mlx4/mlx4_flow.c
> @@ -980,12 +980,13 @@ struct mlx4_drop {
>  	priv->drop = drop;
>  	return drop;
>  error:
> -	if (drop->qp)
> -		claim_zero(mlx4_glue->destroy_qp(drop->qp));
> -	if (drop->cq)
> -		claim_zero(mlx4_glue->destroy_cq(drop->cq));
> -	if (drop)
> +	if (drop) {
> +		if (drop->qp)
> +			claim_zero(mlx4_glue->destroy_qp(drop->qp));
> +		if (drop->cq)
> +			claim_zero(mlx4_glue->destroy_cq(drop->cq));
>  		rte_free(drop);
> +	}
>  	rte_errno = ENOMEM;
>  	return NULL;
>  }
> --
> 1.8.3.1

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-11 13:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-06 16:27 [dpdk-stable] [PATCH] net/mlx4: fix drop queue mem alloc failure handle Michael Baum
2020-05-11 13:33 ` [dpdk-stable] [dpdk-dev] " Raslan Darawsheh

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git