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 385991B33F; Wed, 8 Nov 2017 13:14:20 +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 vA8CEDNF009898; Wed, 8 Nov 2017 12:14:13 GMT Received: (from alucero@localhost) by netronome.com (8.14.4/8.14.4/Submit) id vA8CEDZg009897; Wed, 8 Nov 2017 12:14:13 GMT From: Alejandro Lucero To: dev@dpdk.org Cc: stable@dpdk.org Date: Wed, 8 Nov 2017 12:14:13 +0000 Message-Id: <1510143253-9860-1-git-send-email-alejandro.lucero@netronome.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] net/nfp: fix resource leak X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Nov 2017 12:14:20 -0000 File descriptor is not released in any potential exit path inside the function. Fixes: f37d8a4b67b2 ("net/nfp: add NSP FW upload command") Coverity: 195018 Signed-off-by: Alejandro Lucero --- drivers/net/nfp/nfp_nspu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/nfp/nfp_nspu.c b/drivers/net/nfp/nfp_nspu.c index a2819a1..3c8cdad 100644 --- a/drivers/net/nfp/nfp_nspu.c +++ b/drivers/net/nfp/nfp_nspu.c @@ -351,12 +351,14 @@ RTE_LOG(INFO, PMD, "fw file too big: %" PRIu64 " bytes (%" PRIu64 " max)", (uint64_t)fsize, (uint64_t)size); + close(fw_f); return -EINVAL; } fw_buf = malloc((size_t)size); if (!fw_buf) { RTE_LOG(INFO, PMD, "malloc failed for fw buffer"); + close(fw_f); return -ENOMEM; } memset(fw_buf, 0, size); @@ -367,12 +369,14 @@ "Just %" PRIu64 " of %" PRIu64 " bytes read.", (uint64_t)bytes, (uint64_t)fsize); free(fw_buf); + close(fw_f); return -EIO; } ret = nspu_command(nspu_desc, NSP_CMD_FW_LOAD, 0, 1, fw_buf, 0, bytes); free(fw_buf); + close(fw_f); return ret; } -- 1.9.1