net/nfp: fix resource leak

Message ID 20190408104939.22902-1-alejandro.lucero@netronome.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/nfp: fix resource leak |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing success Performance Testing PASS

Commit Message

Alejandro Lucero April 8, 2019, 10:49 a.m. UTC
  Coverity issue: 32806
Fixes: ef28aa96e53b ("net/nfp: support multiprocess")
Cc: stable@dpdk.org

Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
---
 drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Ferruh Yigit April 8, 2019, 4:50 p.m. UTC | #1
On 4/8/2019 11:49 AM, Alejandro Lucero wrote:
> Coverity issue: 32806
> Fixes: ef28aa96e53b ("net/nfp: support multiprocess")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
index 33baa989b..0b9db974e 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;
 }