From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from netronome.com (host-79-78-33-110.static.as9105.net [79.78.33.110]) by dpdk.org (Postfix) with ESMTP id BD92D1B2CB; Wed, 8 Nov 2017 15:36:39 +0100 (CET) Received: from netronome.com (localhost [127.0.0.1]) by netronome.com (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id vA8EaWCA045420; Wed, 8 Nov 2017 14:36:32 GMT Received: (from alucero@localhost) by netronome.com (8.14.4/8.14.4/Submit) id vA8EaWMJ045419; Wed, 8 Nov 2017 14:36:32 GMT From: Alejandro Lucero To: dev@dpdk.org Cc: stable@dpdk.org Date: Wed, 8 Nov 2017 14:36:32 +0000 Message-Id: <1510151792-45382-1-git-send-email-alejandro.lucero@netronome.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-stable] [PATCH] net/nfp: fix null pointer check X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Nov 2017 14:36:40 -0000 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 --- 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