Skip to contentSkip to conversation

net/softnic: fix resource leak

PATCH Superseded Jasvinder Singh 4 participants 6 messages Apr 27, 2020 – May 13, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/softnic: fix resource leak

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

Coverity Issues: 357676, 357680, 357681, 357682, 357690, 357693, 357711, 357722, 357725, 357734, 357739, 357743, 357747,357762, 357766, 357787

Fixes 6d4d05402501 ("net/softnic: add command to read stats")
Fixes 202905f3ee4d ("net/softnic: add command to create objects")
Fixes ee19326a4b1e ("net/softnic: add command for pipeline table entries")
Fixes 9bc0ce0ad17c ("net/softnic: add command for meter action")
Fixes 2505030a8383 ("net/softnic: add command for TTL action")
---
 drivers/net/softnic/rte_eth_softnic_thread.c | 65 +++++++++++++++-----
 1 file changed, 48 insertions(+), 17 deletions(-)
drivers/net/softnic/rte_eth_softnic_thread.c +48 -17
index 028911c19..f45dbbe1e 100644
@@ -773,9 +773,9 @@ pipeline_msg_alloc(void)
 }
 
 static void
-pipeline_msg_free(struct pipeline_msg_rsp *rsp)
+pipeline_msg_free(void *msg)
 {
-	free(rsp);
+	free(msg);
 }
 
 static struct pipeline_msg_rsp *
@@ -843,8 +843,10 @@ softnic_pipeline_port_in_stats_read(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
+	if (rsp == NULL) {
+		pipeline_msg_free(req);
 		return -1;
+	}
 
 	/* Read response */
 	status = rsp->status;
@@ -892,8 +894,10 @@ softnic_pipeline_port_in_enable(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
+	if (rsp == NULL) {
+		pipeline_msg_free(req);
 		return -1;
+	}
 
 	/* Read response */
 	status = rsp->status;
@@ -939,8 +943,10 @@ softnic_pipeline_port_in_disable(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
+	if (rsp == NULL) {
+		pipeline_msg_free(req);
 		return -1;
+	}
 
 	/* Read response */
 	status = rsp->status;
@@ -994,8 +1000,10 @@ softnic_pipeline_port_out_stats_read(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
+	if (rsp == NULL) {
+		pipeline_msg_free(req);
 		return -1;
+	}
 
 	/* Read response */
 	status = rsp->status;
@@ -1051,8 +1059,10 @@ softnic_pipeline_table_stats_read(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
+	if (rsp == NULL) {
+		pipeline_msg_free(req);
 		return -1;
+	}
 
 	/* Read response */
 	status = rsp->status;
@@ -1331,8 +1341,10 @@ softnic_pipeline_table_rule_add(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
+	if (rsp == NULL) {
+		pipeline_msg_free(req);
 		return -1;
+	}
 
 	/* Read response */
 	status = rsp->status;
@@ -1415,8 +1427,10 @@ softnic_pipeline_table_rule_add_default(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
+	if (rsp == NULL) {
+		pipeline_msg_free(req);
 		return -1;
+	}
 
 	/* Read response */
 	status = rsp->status;
@@ -1573,8 +1587,10 @@ softnic_pipeline_table_rule_add_bulk(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
+	if (rsp == NULL) {
+		pipeline_msg_free(req);
 		return -1;
+	}
 
 	/* Read response */
 	status = rsp->status;
@@ -1638,8 +1654,10 @@ softnic_pipeline_table_rule_delete(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
+	if (rsp == NULL) {
+		pipeline_msg_free(req);
 		return -1;
+	}
 
 	/* Read response */
 	status = rsp->status;
@@ -1688,8 +1706,10 @@ softnic_pipeline_table_rule_delete_default(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
+	if (rsp == NULL) {
+		pipeline_msg_free(req);
 		return -1;
+	}
 
 	/* Read response */
 	status = rsp->status;
@@ -1748,8 +1768,10 @@ softnic_pipeline_table_rule_stats_read(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
+	if (rsp == NULL) {
+		pipeline_msg_free(req);
 		return -1;
+	}
 
 	/* Read response */
 	status = rsp->status;
@@ -1831,6 +1853,7 @@ softnic_pipeline_table_mtr_profile_add(struct pmd_internals *softnic,
 	rsp = pipeline_msg_send_recv(p, req);
 	if (rsp == NULL) {
 		free(mp);
+		pipeline_msg_free(req);
 		return -1;
 	}
 
@@ -1888,8 +1911,10 @@ softnic_pipeline_table_mtr_profile_delete(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
+	if (rsp == NULL) {
+		pipeline_msg_free(req);
 		return -1;
+	}
 
 	/* Read response */
 	status = rsp->status;
@@ -1951,8 +1976,10 @@ softnic_pipeline_table_rule_mtr_read(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
+	if (rsp == NULL) {
+		pipeline_msg_free(req);
 		return -1;
+	}
 
 	/* Read response */
 	status = rsp->status;
@@ -2016,8 +2043,10 @@ softnic_pipeline_table_dscp_table_update(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
+	if (rsp == NULL) {
+		pipeline_msg_free(req);
 		return -1;
+	}
 
 	/* Read response */
 	status = rsp->status;
@@ -2081,8 +2110,10 @@ softnic_pipeline_table_rule_ttl_read(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
+	if (rsp == NULL) {
+		pipeline_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 resource leak for pipeline

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

Coverity Issues: 357676, 357680, 357681, 357682, 357690, 357693, 357711, 357722, 357725, 357734, 357739, 357743, 357747,357762, 357766, 357787

Fixes 6d4d05402501 ("net/softnic: add command to read stats")
Fixes 202905f3ee4d ("net/softnic: add command to create objects")
Fixes ee19326a4b1e ("net/softnic: add command for pipeline table entries")
Fixes 9bc0ce0ad17c ("net/softnic: add command for meter action")
Fixes 2505030a8383 ("net/softnic: add command for TTL action")
---
 drivers/net/softnic/rte_eth_softnic_thread.c | 34 --------------------
 1 file changed, 34 deletions(-)
drivers/net/softnic/rte_eth_softnic_thread.c +0 -34
index d61846e03..dcfb5eb82 100644
@@ -835,8 +835,6 @@ softnic_pipeline_port_in_stats_read(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
-		return -1;
 
 	/* Read response */
 	status = rsp->status;
@@ -884,8 +882,6 @@ softnic_pipeline_port_in_enable(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
-		return -1;
 
 	/* Read response */
 	status = rsp->status;
@@ -931,8 +927,6 @@ softnic_pipeline_port_in_disable(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
-		return -1;
 
 	/* Read response */
 	status = rsp->status;
@@ -986,8 +980,6 @@ softnic_pipeline_port_out_stats_read(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
-		return -1;
 
 	/* Read response */
 	status = rsp->status;
@@ -1043,8 +1035,6 @@ softnic_pipeline_table_stats_read(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
-		return -1;
 
 	/* Read response */
 	status = rsp->status;
@@ -1323,8 +1313,6 @@ softnic_pipeline_table_rule_add(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
-		return -1;
 
 	/* Read response */
 	status = rsp->status;
@@ -1407,8 +1395,6 @@ softnic_pipeline_table_rule_add_default(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
-		return -1;
 
 	/* Read response */
 	status = rsp->status;
@@ -1565,8 +1551,6 @@ softnic_pipeline_table_rule_add_bulk(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
-		return -1;
 
 	/* Read response */
 	status = rsp->status;
@@ -1630,8 +1614,6 @@ softnic_pipeline_table_rule_delete(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
-		return -1;
 
 	/* Read response */
 	status = rsp->status;
@@ -1680,8 +1662,6 @@ softnic_pipeline_table_rule_delete_default(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
-		return -1;
 
 	/* Read response */
 	status = rsp->status;
@@ -1740,8 +1720,6 @@ softnic_pipeline_table_rule_stats_read(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
-		return -1;
 
 	/* Read response */
 	status = rsp->status;
@@ -1821,10 +1799,6 @@ softnic_pipeline_table_mtr_profile_add(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL) {
-		free(mp);
-		return -1;
-	}
 
 	/* Read response */
 	status = rsp->status;
@@ -1880,8 +1854,6 @@ softnic_pipeline_table_mtr_profile_delete(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
-		return -1;
 
 	/* Read response */
 	status = rsp->status;
@@ -1943,8 +1915,6 @@ softnic_pipeline_table_rule_mtr_read(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
-		return -1;
 
 	/* Read response */
 	status = rsp->status;
@@ -2008,8 +1978,6 @@ softnic_pipeline_table_dscp_table_update(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, req);
-	if (rsp == NULL)
-		return -1;
 
 	/* Read response */
 	status = rsp->status;
@@ -2073,8 +2041,6 @@ softnic_pipeline_table_rule_ttl_read(struct pmd_internals *softnic,
 
 	/* Send request and wait for response */
 	rsp = pipeline_msg_send_recv(p, 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 resource leak for pipeline

Quoted 8 lines · Jasvinder Singh

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

Coverity Issues: 357676, 357680, 357681, 357682, 357690, 357693, 357711, 357722, 357725, 357734, 357739, 357743, 357747,357762, 357766, 357787

Quoted 8 lines
Fixes 6d4d05402501 ("net/softnic: add command to read stats")
Fixes 202905f3ee4d ("net/softnic: add command to create objects")
Fixes ee19326a4b1e ("net/softnic: add command for pipeline table entries")
Fixes 9bc0ce0ad17c ("net/softnic: add command for meter action")
Fixes 2505030a8383 ("net/softnic: add command for TTL action")

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

#3 lore raw
In reply to Jasvinder Singh
Quoted 13 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Jasvinder Singh
Sent: Monday, April 27, 2020 3:03 PM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>
Subject: [dpdk-dev] [PATCH] net/softnic: fix resource leak

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

Coverity Issues: 357676, 357680, 357681, 357682, 357690, 357693, 357711, 357722, 357725, 357734, 357739, 357743, 357747,357762, 357766, 357787

Quoted 8 lines
Fixes 6d4d05402501 ("net/softnic: add command to read stats")
Fixes 202905f3ee4d ("net/softnic: add command to create objects")
Fixes ee19326a4b1e ("net/softnic: add command for pipeline table

entries")

Fixes 9bc0ce0ad17c ("net/softnic: add command for meter action")
Fixes 2505030a8383 ("net/softnic: add command for TTL action")

Cristian,

Can you merge this and other Coverity fixes. They need to be cleared for DPDK 20.05.

John

#4 lore raw
Quoted 35 lines

-----Original Message-----
From: Mcnamara, John <[email protected]>
Sent: Wednesday, May 13, 2020 1:46 PM
To: Dumitrescu, Cristian <[email protected]>
Cc: [email protected]; Singh, Jasvinder <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/softnic: fix resource leak

Quoted 9 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Jasvinder Singh
Sent: Monday, April 27, 2020 3:03 PM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>
Subject: [dpdk-dev] [PATCH] net/softnic: fix resource leak

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

response.

Quoted 4 lines

Coverity Issues: 357676, 357680, 357681, 357682, 357690, 357693, 357711, 357722, 357725, 357734, 357739, 357743, 357747,357762, 357766, 357787

Quoted 8 lines
Fixes 6d4d05402501 ("net/softnic: add command to read stats")
Fixes 202905f3ee4d ("net/softnic: add command to create objects")
Fixes ee19326a4b1e ("net/softnic: add command for pipeline table

entries")

Fixes 9bc0ce0ad17c ("net/softnic: add command for meter action")
Fixes 2505030a8383 ("net/softnic: add command for TTL action")
Quoted 6 lines

Cristian,

Can you merge this and other Coverity fixes. They need to be cleared for DPDK 20.05.

John

Ferruh and Jasvinder confirmed these are already merged.

#5 lore raw
Quoted 35 lines · Cristian
Quoted 35 lines

-----Original Message-----
From: Mcnamara, John <[email protected]>
Sent: Wednesday, May 13, 2020 1:46 PM
To: Dumitrescu, Cristian <[email protected]>
Cc: [email protected]; Singh, Jasvinder <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/softnic: fix resource leak

Quoted 9 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Jasvinder Singh
Sent: Monday, April 27, 2020 3:03 PM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>
Subject: [dpdk-dev] [PATCH] net/softnic: fix resource leak

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

response.

Quoted 12 lines

Coverity Issues: 357676, 357680, 357681, 357682, 357690, 357693, 357711, 357722, 357725, 357734, 357739, 357743, 357747,357762, 357766, 357787

Fixes 6d4d05402501 ("net/softnic: add command to read stats")
Fixes 202905f3ee4d ("net/softnic: add command to create objects")
Fixes ee19326a4b1e ("net/softnic: add command for pipeline table

entries")

Fixes 9bc0ce0ad17c ("net/softnic: add command for meter action")
Fixes 2505030a8383 ("net/softnic: add command for TTL action")
Quoted 9 lines
Quoted 6 lines

Cristian,

Can you merge this and other Coverity fixes. They need to be cleared for DPDK 20.05.

John

Ferruh and Jasvinder confirmed these are already merged.

Patches are in the tree Cristian, but I think they are not addressing the coverity issue correctly, that looks the reason that coverity issues are still there.