From 965f0aaa7c59355495a1035dd7b991d47a9cb24e Mon Sep 17 00:00:00 2001 From: Alejandro Lucero Date: Wed, 8 Nov 2017 12:07:14 +0000 Subject: [PATCH] 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 --- 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 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)); -- 2.20.1