summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Lucero <alejandro.lucero@netronome.com>2017-11-08 12:07:14 +0000
committerFerruh Yigit <ferruh.yigit@intel.com>2017-11-10 09:31:24 +0000
commit965f0aaa7c59355495a1035dd7b991d47a9cb24e (patch)
treeca2bbb5e32d69a9374a19fb49993a952d8ac2969
parent9b634927a71d555ec7314e177d8698347b5cc8e0 (diff)
downloaddpdk-965f0aaa7c59355495a1035dd7b991d47a9cb24e.zip
dpdk-965f0aaa7c59355495a1035dd7b991d47a9cb24e.tar.gz
dpdk-965f0aaa7c59355495a1035dd7b991d47a9cb24e.tar.xz
net/nfp: fix memory allocation
If the function actually returns a null value, a null pointer dereference will occur. Coverity issue: 195013 Fixes: dd63df2bfff3 ("net/nfp: add NSP symbol resolution command") Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
-rw-r--r--drivers/net/nfp/nfp_nspu.c3
1 files changed, 3 insertions, 0 deletions
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 @@ nfp_nspu_set_bar_from_symbl(nspu_desc_t *desc, const char *symbl,
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));