Skip to contentSkip to conversation

net/softnic: fix memory leak

PATCH Superseded Jasvinder Singh 2 participants 3 messages Apr 27, 2020 – May 1, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/softnic: fix memory leak

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")
---
 drivers/net/softnic/rte_eth_softnic_thread.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/softnic/rte_eth_softnic_thread.c +8 -4
index d610b1617..028911c19 100644
@@ -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;
Signature · 1 line
2.21.1
#1 lore raw

PATCH v2 1/1 net/softnic: fix memory leak for thread

For sending request messages to data plane threads, the caller invokes thread_msg_send_recv() function which never returns null response. Thus, removed redundant check on the returned response.

Coverity Issue: 357717, 357772

Fixes 70709c78fda6 ("net/softnic: add command to enable/disable pipeline")

---
v2:
- change commit message

 drivers/net/softnic/rte_eth_softnic_thread.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/net/softnic/rte_eth_softnic_thread.c +0 -4
index d610b1617..d61846e03 100644
@@ -359,8 +359,6 @@ 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)
-		return -1;
 
 	/* Read response */
 	status = rsp->status;
@@ -444,8 +442,6 @@ 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)
-		return -1;
 
 	/* Read response */
 	status = rsp->status;
Signature · 1 line
2.21.1
Applied
#2 lore raw

Re: [dpdk-dev] [PATCH v2] net/softnic: fix memory leak for thread

Quoted 10 lines · Jasvinder Singh

For sending request messages to data plane threads, the caller invokes thread_msg_send_recv() function which never returns null response. Thus, removed redundant check on the returned response.

Coverity Issue: 357717, 357772

Fixes 70709c78fda6 ("net/softnic: add command to enable/disable pipeline")

Applied to dpdk-next-net/master, thanks.