From: Alejandro Lucero Date: Wed, 8 Nov 2017 12:07:14 +0000 (+0000) Subject: net/nfp: fix memory allocation X-Git-Tag: spdx-start~863 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=965f0aaa7c59355495a1035dd7b991d47a9cb24e;p=dpdk.git 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 --- diff --git a/drivers/net/nfp/nfp_nspu.c b/drivers/net/nfp/nfp_nspu.c index 6ba940cbf9..a2819a14ee 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));