summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Lucero <alejandro.lucero@netronome.com>2017-11-08 12:14:13 +0000
committerFerruh Yigit <ferruh.yigit@intel.com>2017-11-10 09:31:24 +0000
commiteb04bc1052e10188ac709658a5b794bdd31e9aa9 (patch)
tree4c59836b66c178457bf4ebab634b969856b75dc3
parent965f0aaa7c59355495a1035dd7b991d47a9cb24e (diff)
downloaddpdk-eb04bc1052e10188ac709658a5b794bdd31e9aa9.zip
dpdk-eb04bc1052e10188ac709658a5b794bdd31e9aa9.tar.gz
dpdk-eb04bc1052e10188ac709658a5b794bdd31e9aa9.tar.xz
net/nfp: fix resource leak
File descriptor is not released in any potential exit path inside the function. Coverity issue: 195018 Fixes: f37d8a4b67b2 ("net/nfp: add NSP FW upload command") Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
-rw-r--r--drivers/net/nfp/nfp_nspu.c4
1 files changed, 4 insertions, 0 deletions
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 @@ nfp_fw_upload(nspu_desc_t *nspu_desc)
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 @@ nfp_fw_upload(nspu_desc_t *nspu_desc)
"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;
}