DPDK patches and discussions
 help / color / mirror / Atom feed
From: Alejandro Lucero <alejandro.lucero@netronome.com>
To: dev@dpdk.org
Cc: stable@dpdk.org
Subject: [dpdk-dev] [PATCH] net/nfp: fix null pointer check
Date: Wed,  8 Nov 2017 14:36:32 +0000	[thread overview]
Message-ID: <1510151792-45382-1-git-send-email-alejandro.lucero@netronome.com> (raw)

First, the received pointer was not checked before. Then the pointer
from malloc was not the one used in the existing check.

Fixes: ad60bca34899 ("net/nfp: read PF port MAC addr using NSP")
Coverity: 195027

Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
---
 drivers/net/nfp/nfp_nspu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/nfp/nfp_nspu.c b/drivers/net/nfp/nfp_nspu.c
index 39d14e6..0b415fc 100644
--- a/drivers/net/nfp/nfp_nspu.c
+++ b/drivers/net/nfp/nfp_nspu.c
@@ -618,10 +618,14 @@
 {
 	int ret;
 
+	if (!table)
+		return -EINVAL;
+
 	RTE_LOG(INFO, PMD, "Reading hw ethernet table...\n");
+
 	/* port 0 allocates the eth table and read it using NSPU */
 	*table = malloc(NSP_ETH_TABLE_SIZE);
-	if (!table)
+	if (!*table)
 		return -ENOMEM;
 
 	ret = nspu_command(desc, NSP_CMD_READ_ETH_TABLE, 1, 0, *table,
-- 
1.9.1

             reply	other threads:[~2017-11-08 14:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-08 14:36 Alejandro Lucero [this message]
2017-11-10  9:38 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit

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=1510151792-45382-1-git-send-email-alejandro.lucero@netronome.com \
    --to=alejandro.lucero@netronome.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    /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).