DPDK patches and discussions
 help / color / mirror / Atom feed
From: Alejandro Lucero <alejandro.lucero@netronome.com>
To: dev@dpdk.org
Cc: stable@dpdk.org
Subject: [dpdk-dev] [PATCH] net/nfp: fix memory leak
Date: Mon,  8 Apr 2019 11:19:29 +0100	[thread overview]
Message-ID: <20190408101929.30970-1-alejandro.lucero@netronome.com> (raw)
Message-ID: <20190408101929.SsyDqsKvWNU2FeeM6iN4sRzU_TqUmiPmEyhri9r9V-c@z> (raw)

If errors, release the allocated structure.

Coverity issue: 277222
Fixes: c7e9729da6b5 ("net/nfp: support CPP")
Cc: stable@dpdk.org

Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
---
 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


             reply	other threads:[~2019-04-08 10:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-08 10:19 Alejandro Lucero [this message]
2019-04-08 10:19 ` Alejandro Lucero
2019-04-08 16:40 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
2019-04-08 16:40   ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190408101929.30970-1-alejandro.lucero@netronome.com \
    --to=alejandro.lucero@netronome.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).