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 630911B342; Wed, 8 Nov 2017 13:19:55 +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 vA8CJmmG010130; Wed, 8 Nov 2017 12:19:48 GMT Received: (from alucero@localhost) by netronome.com (8.14.4/8.14.4/Submit) id vA8CJmJC010129; Wed, 8 Nov 2017 12:19:48 GMT From: Alejandro Lucero To: dev@dpdk.org Cc: stable@dpdk.org Date: Wed, 8 Nov 2017 12:19:48 +0000 Message-Id: <1510143588-10092-1-git-send-email-alejandro.lucero@netronome.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-stable] [PATCH] net/nfp: check function return value 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:19:55 -0000 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. Fixes: f37d8a4b67b2 ("net/nfp: add NSP FW upload command") Coverity: 195019 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 3c8cdad..39d14e6 100644 --- a/drivers/net/nfp/nfp_nspu.c +++ b/drivers/net/nfp/nfp_nspu.c @@ -341,7 +341,12 @@ 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", -- 1.9.1