From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 98C7EA0096 for ; Mon, 8 Apr 2019 12:19:33 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 644984CA9; Mon, 8 Apr 2019 12:19:31 +0200 (CEST) Received: from netronome.com (unknown [217.38.71.146]) by dpdk.org (Postfix) with ESMTP id D2A5B2C24; Mon, 8 Apr 2019 12:19:29 +0200 (CEST) Received: from netronome.com (localhost [127.0.0.1]) by netronome.com (8.15.2/8.15.2/Debian-10) with ESMTP id x38AJTib031016; Mon, 8 Apr 2019 11:19:29 +0100 Received: (from root@localhost) by netronome.com (8.15.2/8.15.2/Submit) id x38AJT2U031015; Mon, 8 Apr 2019 11:19:29 +0100 From: Alejandro Lucero To: dev@dpdk.org Cc: stable@dpdk.org Date: Mon, 8 Apr 2019 11:19:29 +0100 Message-Id: <20190408101929.30970-1-alejandro.lucero@netronome.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] net/nfp: fix memory 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190408101929.SsyDqsKvWNU2FeeM6iN4sRzU_TqUmiPmEyhri9r9V-c@z> If errors, release the allocated structure. Coverity issue: 277222 Fixes: c7e9729da6b5 ("net/nfp: support CPP") Cc: stable@dpdk.org Signed-off-by: Alejandro Lucero --- drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c index 93ee310f5..33baa989b 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 -- 2.17.1