net/softnic: fix memory leak
Checks
Commit Message
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(-)
@@ -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;