From f5cba91b095d54e8d7fcea57e515b5b4453b02ba Mon Sep 17 00:00:00 2001 From: Alejandro Lucero Date: Wed, 8 Nov 2017 12:19:48 +0000 Subject: [PATCH] net/nfp: fix checking function return value The fstat function could return a value that indicates an error condition. If this is not checked, the error condition may not be handled correctly. Coverity issue: 195019 Fixes: f37d8a4b67b2 ("net/nfp: add NSP FW upload command") Signed-off-by: Alejandro Lucero --- drivers/net/nfp/nfp_nspu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/nfp/nfp_nspu.c b/drivers/net/nfp/nfp_nspu.c index 3c8cdadcf2..39d14e6acd 100644 --- a/drivers/net/nfp/nfp_nspu.c +++ b/drivers/net/nfp/nfp_nspu.c @@ -341,7 +341,12 @@ nfp_fw_upload(nspu_desc_t *nspu_desc) return -ENOENT; } - fstat(fw_f, &file_stat); + if (fstat(fw_f, &file_stat) < 0) { + RTE_LOG(INFO, PMD, "Firmware file %s/%s size is unknown", + DEFAULT_FW_PATH, DEFAULT_FW_FILENAME); + close(fw_f); + return -ENOENT; + } fsize = file_stat.st_size; RTE_LOG(DEBUG, PMD, "Firmware file with size: %" PRIu64 "\n", -- 2.20.1