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 9FC741B341; Wed, 8 Nov 2017 13:07:21 +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 vA8C7ET0041333; Wed, 8 Nov 2017 12:07:14 GMT Received: (from alucero@localhost) by netronome.com (8.14.4/8.14.4/Submit) id vA8C7EO3041332; Wed, 8 Nov 2017 12:07:14 GMT From: Alejandro Lucero To: dev@dpdk.org Cc: stable@dpdk.org Date: Wed, 8 Nov 2017 12:07:14 +0000 Message-Id: <1510142834-41295-1-git-send-email-alejandro.lucero@netronome.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-stable] [PATCH] net/nfp: fix memory allocation 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 12:07:21 -0000 If the function actually returns a null value, a null pointer dereference will occur. Fixes: dd63df2bfff3 ("net/nfp: add NSP symbol resolution command") Coverity: 195013 Signed-off-by: Alejandro Lucero --- drivers/net/nfp/nfp_nspu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/nfp/nfp_nspu.c b/drivers/net/nfp/nfp_nspu.c index 6ba940c..a2819a1 100644 --- a/drivers/net/nfp/nfp_nspu.c +++ b/drivers/net/nfp/nfp_nspu.c @@ -411,6 +411,9 @@ int ret = 0; sym_buf = malloc(desc->buf_size); + if (!sym_buf) + return -ENOMEM; + strncpy(sym_buf, symbl, strlen(symbl)); ret = nspu_command(desc, NSP_CMD_GET_SYMBOL, 1, 1, sym_buf, NFP_SYM_DESC_LEN, strlen(symbl)); -- 1.9.1