DPDK patches and discussions
 help / color / mirror / Atom feed
From: Michael Baum <michaelba@mellanox.com>
To: dev@dpdk.org
Cc: Matan Azrad <matan@mellanox.com>,
	Viacheslav Ovsiienko <viacheslavo@mellanox.com>,
	stable@dpdk.org
Subject: [dpdk-dev] [PATCH] net/mlx4: fix drop queue mem alloc failure handle
Date: Wed,  6 May 2020 16:27:54 +0000	[thread overview]
Message-ID: <1588782474-17314-1-git-send-email-michaelba@mellanox.com> (raw)

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


             reply	other threads:[~2020-05-06 16:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06 16:27 Michael Baum [this message]
2020-05-11 13:33 ` Raslan Darawsheh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1588782474-17314-1-git-send-email-michaelba@mellanox.com \
    --to=michaelba@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=matan@mellanox.com \
    --cc=stable@dpdk.org \
    --cc=viacheslavo@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).