Skip to contentSkip to conversation

app/testpmd: fix memory leak in port flow configure

PATCH Applied Shani Peretz 3 participants 4 messages Mar 24

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 app/testpmd: fix memory leak in port flow configure

When "flow configure" is issued multiple times on the same port, port_flow_configure() allocates a new job_list via calloc() without freeing the previous allocation, leaking it. The old pointer is simply overwritten.

testpmd> flow configure 0 queues_number 10 queues_size 256 ... testpmd> flow configure 0 queues_number 10 queues_size 256 ...

The patch fixes this by freeing the existing job_list before allocating the replacement.

Fixes df503d757b36 ("app/testpmd: fix flow queue job leaks")
---
 app/test-pmd/config.c | 1 +
 1 file changed, 1 insertion(+)
app/test-pmd/config.c +1 -0
index f9f3c542a6..f0a784bf2f 100644
@@ -1836,6 +1836,7 @@ port_flow_configure(portid_t port_id,
 	port->queue_sz = queue_attr->size;
 	for (std_queue = 0; std_queue < nb_queue; std_queue++)
 		attr_list[std_queue] = queue_attr;
+	free(port->job_list);
 	port->job_list = calloc(nb_queue, sizeof(*port->job_list));
 	if (port->job_list == NULL) {
 		TESTPMD_LOG(ERR, "Failed to allocate memory for operations tracking on port %u\n",
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines

-----Original Message-----
From: Shani Peretz <[email protected]>
Sent: Tuesday, March 24, 2026 9:11 AM
To: [email protected]
Cc: Shani Peretz <[email protected]>; [email protected]; Aman Singh <[email protected]>; Dariusz Sosnowski <[email protected]>
Subject: [PATCH] app/testpmd: fix memory leak in port flow configure

When "flow configure" is issued multiple times on the same port, port_flow_configure() allocates a new job_list via calloc() without freeing the previous allocation, leaking it. The old pointer is simply overwritten.

testpmd> flow configure 0 queues_number 10 queues_size 256 ... testpmd> flow configure 0 queues_number 10 queues_size 256 ...

Quoted 7 lines

The patch fixes this by freeing the existing job_list before allocating the replacement.

Fixes df503d757b36 ("app/testpmd: fix flow queue job leaks")

Best regards,
Dariusz Sosnowski

#2 lore raw
In reply to Shani Peretz
Quoted 24 lines · On Tue, 24 Mar 2026 10:10:44 +0200 Shani Peretz <[email protected]> wrote:

When "flow configure" is issued multiple times on the same port, port_flow_configure() allocates a new job_list via calloc() without freeing the previous allocation, leaking it. The old pointer is simply overwritten.

testpmd> flow configure 0 queues_number 10 queues_size 256 ... testpmd> flow configure 0 queues_number 10 queues_size 256 ...

The patch fixes this by freeing the existing job_list before allocating the replacement.

Fixes df503d757b36 ("app/testpmd: fix flow queue job leaks")
---
 app/test-pmd/config.c | 1 +
 1 file changed, 1 insertion(+)
app/test-pmd/config.c +0 -0
index f9f3c542a6..f0a784bf2f 100644

app/test-pmd/config.c port_flow_configure(portid_t port_id, · line 1840

Quoted 5 lines
app/test-pmd/config.c +1 -0
@@ -1836,6 +1836,7 @@ port_flow_configure(portid_t port_id,
 	port->queue_sz = queue_attr->size;
 	for (std_queue = 0; std_queue < nb_queue; std_queue++)
 		attr_list[std_queue] = queue_attr;
+	free(port->job_list);
 	port->job_list = calloc(nb_queue, sizeof(*port->job_list));

You could use realloc here, but it doesn't matter much

#3 lore raw
In reply to Shani Peretz
Quoted 8 lines · On Tue, 24 Mar 2026 10:10:44 +0200 Shani Peretz <[email protected]> wrote:

When "flow configure" is issued multiple times on the same port, port_flow_configure() allocates a new job_list via calloc() without freeing the previous allocation, leaking it. The old pointer is simply overwritten.

testpmd> flow configure 0 queues_number 10 queues_size 256 ... testpmd> flow configure 0 queues_number 10 queues_size 256 ...

Quoted 7 lines

The patch fixes this by freeing the existing job_list before allocating the replacement.

Fixes df503d757b36 ("app/testpmd: fix flow queue job leaks")

Applied to next-net