diff mbox series

net/softnic: fix memory leak

Message ID 20200427140556.83262-1-jasvinder.singh@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show
Series net/softnic: fix memory leak | expand

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Jasvinder Singh April 27, 2020, 2:05 p.m. UTC
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 mbox series

Patch

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;