From: Alejandro Lucero Date: Mon, 8 Apr 2019 10:49:39 +0000 (+0100) Subject: net/nfp: fix memory leak X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=8539ec0a40a332da568f2bfac4419f6f9116668e;p=dpdk.git net/nfp: fix memory leak Coverity issue: 32806 Fixes: ef28aa96e53b ("net/nfp: support multiprocess") Cc: stable@dpdk.org Signed-off-by: Alejandro Lucero --- diff --git a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c index 33baa989b5..0b9db974e1 100644 --- a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c +++ b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c @@ -690,12 +690,16 @@ nfp_acquire_secondary_process_lock(struct nfp_pcie_user *desc) lockfile = calloc(strlen(home_path) + strlen(lockname) + 1, sizeof(char)); + if (!lockfile) + return -ENOMEM; + strcat(lockfile, home_path); strcat(lockfile, "/.lock_nfp_secondary"); desc->secondary_lock = open(lockfile, O_RDWR | O_CREAT | O_NONBLOCK, 0666); if (desc->secondary_lock < 0) { RTE_LOG(ERR, PMD, "NFP lock for secondary process failed\n"); + free(lockfile); return desc->secondary_lock; } @@ -707,6 +711,7 @@ nfp_acquire_secondary_process_lock(struct nfp_pcie_user *desc) close(desc->secondary_lock); } + free(lockfile); return rc; }