DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jasvinder Singh <jasvinder.singh@intel.com>
To: dev@dpdk.org
Cc: cristian.dumitrescu@intel.com
Subject: [dpdk-dev] [PATCH] net/softnic: fix memory leak
Date: Mon, 27 Apr 2020 15:05:56 +0100	[thread overview]
Message-ID: <20200427140556.83262-1-jasvinder.singh@intel.com> (raw)

When sending request messages to data plane thread, the
caller must free the memory allocated to request message
on receiving error response.

Coverity Issue: 357717, 357772
Fixes: 70709c78fda6 ("net/softnic: add command to enable/disable pipeline")

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
---
 drivers/net/softnic/rte_eth_softnic_thread.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/net/softnic/rte_eth_softnic_thread.c b/drivers/net/softnic/rte_eth_softnic_thread.c
index d610b1617..028911c19 100644
--- a/drivers/net/softnic/rte_eth_softnic_thread.c
+++ b/drivers/net/softnic/rte_eth_softnic_thread.c
@@ -255,9 +255,9 @@ thread_msg_alloc(void)
 }
 
 static void
-thread_msg_free(struct thread_msg_rsp *rsp)
+thread_msg_free(void *msg)
 {
-	free(rsp);
+	free(msg);
 }
 
 static struct thread_msg_rsp *
@@ -359,8 +359,10 @@ softnic_thread_pipeline_enable(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = thread_msg_send_recv(softnic, thread_id, req);
-	if (rsp == NULL)
+	if (rsp == NULL) {
+		thread_msg_free(req);
 		return -1;
+	}
 
 	/* Read response */
 	status = rsp->status;
@@ -444,8 +446,10 @@ softnic_thread_pipeline_disable(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = thread_msg_send_recv(softnic, thread_id, req);
-	if (rsp == NULL)
+	if (rsp == NULL) {
+		thread_msg_free(req);
 		return -1;
+	}
 
 	/* Read response */
 	status = rsp->status;
-- 
2.21.1


             reply	other threads:[~2020-04-27 14:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-27 14:05 Jasvinder Singh [this message]
2020-04-27 17:13 ` [dpdk-dev] [PATCH v2] net/softnic: fix memory leak for thread Jasvinder Singh
2020-05-01 15:47   ` 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=20200427140556.83262-1-jasvinder.singh@intel.com \
    --to=jasvinder.singh@intel.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@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).