From: Alejandro Lucero Date: Mon, 8 Apr 2019 10:19:29 +0000 (+0100) Subject: net/nfp: fix memory leak X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=318e737d2d04899733539c63aab84bf0b2cf0552;p=dpdk.git net/nfp: fix memory leak If errors, release the allocated structure. Coverity issue: 277222 Fixes: c7e9729da6b5 ("net/nfp: support CPP") 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 93ee310f58..33baa989b5 100644 --- a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c +++ b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c @@ -865,24 +865,24 @@ nfp6000_init(struct nfp_cpp *cpp, struct rte_pci_device *dev) cpp->driver_lock_needed) { ret = nfp_acquire_process_lock(desc); if (ret) - return -1; + goto error; } /* Just support for one secondary process */ if (rte_eal_process_type() != RTE_PROC_PRIMARY) { ret = nfp_acquire_secondary_process_lock(desc); if (ret) - return -1; + goto error; } if (nfp6000_set_model(dev, cpp) < 0) - return -1; + goto error; if (nfp6000_set_interface(dev, cpp) < 0) - return -1; + goto error; if (nfp6000_set_serial(dev, cpp) < 0) - return -1; + goto error; if (nfp6000_set_barsz(dev, desc) < 0) - return -1; + goto error; desc->cfg = (char *)dev->mem_resource[0].addr; @@ -890,7 +890,11 @@ nfp6000_init(struct nfp_cpp *cpp, struct rte_pci_device *dev) nfp_cpp_priv_set(cpp, desc); - return ret; + return 0; + +error: + free(desc); + return -1; } static void