Skip to contentSkip to conversation

app/testpmd: fix action destruction memory leak

PATCH Applied Suanming Mou 3 participants 5 messages Nov 17, 2022 – Nov 18, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 app/testpmd: fix action destruction memory leak

In case action handle destroy fails, the job memory was not freed properly. This commit fixes the possible memory leak in the action handle destruction failed case.

Fixes c9dc03840873 ("ethdev: add indirect action async query")
---
 app/test-pmd/config.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/config.c +2 -2
index 982549ffed..719bdd4261 100644
@@ -2873,9 +2873,9 @@ port_queue_action_handle_destroy(portid_t port_id,
 			job->type = QUEUE_JOB_TYPE_ACTION_DESTROY;
 			job->pia = pia;
 
-			if (pia->handle &&
-			    rte_flow_async_action_handle_destroy(port_id,
+			if (rte_flow_async_action_handle_destroy(port_id,
 				queue_id, &attr, pia->handle, job, &error)) {
+				free(job);
 				ret = port_flow_complain(&error);
 				continue;
 			}
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Suanming Mou

In case action handle destroy fails, the job memory was not freed properly. This commit fixes the possible memory leak in the action handle destruction failed case.

Fixes c9dc03840873 ("ethdev: add indirect action async query")
Quoted 1 line

LGTM.

Thanks.

Signature · 1 line
David Marchand
#2 lore raw
In reply to Suanming Mou
Quoted 16 lines · Suanming Mou

In case action handle destroy fails, the job memory was not freed properly. This commit fixes the possible memory leak in the action handle destruction failed case.

Fixes c9dc03840873 ("ethdev: add indirect action async query")
---
 app/test-pmd/config.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/config.c +0 -0
index 982549ffed..719bdd4261 100644

app/test-pmd/config.c port_queue_action_handle_destroy(portid_t port_id, · line 2876

Quoted 6 lines
app/test-pmd/config.c +1 -2
@@ -2873,9 +2873,9 @@ port_queue_action_handle_destroy(portid_t port_id,
 			job->type = QUEUE_JOB_TYPE_ACTION_DESTROY;
 			job->pia = pia;
 
-			if (pia->handle &&
-			    rte_flow_async_action_handle_destroy(port_id,
+			if (rte_flow_async_action_handle_destroy(port_id,

Why 'pia->handle' check removed, was it unnecessary to check it at first place?

app/test-pmd/config.c port_queue_action_handle_destroy(portid_t port_id, · line 2881

Quoted 5 lines
app/test-pmd/config.c +1 -0
 				queue_id, &attr, pia->handle, job, &error)) {
+				free(job);
 				ret = port_flow_complain(&error);
 				continue;
 			}

Just to double check, when this if branch not taken, 'rte_flow_async_action_handle_destroy()' not failed case, testpmd 'port_queue_flow_pull()' functions frees the 'job', right?

#3 lore raw

Hi,

Quoted 36 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Friday, November 18, 2022 6:40 PM
To: Suanming Mou <[email protected]>; [email protected]; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] app/testpmd: fix action destruction memory leak

app/test-pmd/config.c port_queue_action_handle_destroy(portid_t

Quoted 16 lines · Suanming Mou

In case action handle destroy fails, the job memory was not freed properly. This commit fixes the possible memory leak in the action handle destruction failed case.

Fixes c9dc03840873 ("ethdev: add indirect action async query")
---
 app/test-pmd/config.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/config.c index renamed from app/test-pmd/config.c +0 -0

982549ffed..719bdd4261 100644

app/test-pmd/config.c +0 -0
@@ -2873,9 +2873,9 @@ port_queue_action_handle_destroy(portid_t

port_id,

app/test-pmd/config.c port_queue_action_handle_destroy(portid_t port_id, · line 2876

Quoted 6 lines
app/test-pmd/config.c +1 -2
 			job->type = QUEUE_JOB_TYPE_ACTION_DESTROY;
 			job->pia = pia;
 
-			if (pia->handle &&
-			    rte_flow_async_action_handle_destroy(port_id,
+			if (rte_flow_async_action_handle_destroy(port_id,

Why 'pia->handle' check removed, was it unnecessary to check it at first place?

Quoted 9 lines

app/test-pmd/config.c port_queue_action_handle_destroy(portid_t port_id, · line 2881

Quoted 5 lines
app/test-pmd/config.c +1 -0
 				queue_id, &attr, pia->handle, job, &error)) {
+				free(job);
 				ret = port_flow_complain(&error);
 				continue;
 			}

Just to double check, when this if branch not taken, 'rte_flow_async_action_handle_destroy()' not failed case, testpmd 'port_queue_flow_pull()' functions frees the 'job', right?

Yes, port_queue_flow_pull() will free the 'job'.

Applied
#4 lore raw
Quoted 37 lines · Suanming Mou

Hi,

Quoted 35 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Friday, November 18, 2022 6:40 PM
To: Suanming Mou <[email protected]>; [email protected]; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] app/testpmd: fix action destruction memory leak

app/test-pmd/config.c port_queue_action_handle_destroy(portid_t

Quoted 16 lines · Suanming Mou

In case action handle destroy fails, the job memory was not freed properly. This commit fixes the possible memory leak in the action handle destruction failed case.

Fixes c9dc03840873 ("ethdev: add indirect action async query")
---
 app/test-pmd/config.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/config.c index renamed from app/test-pmd/config.c +0 -0

982549ffed..719bdd4261 100644

app/test-pmd/config.c +0 -0
@@ -2873,9 +2873,9 @@ port_queue_action_handle_destroy(portid_t

port_id,

app/test-pmd/config.c port_queue_action_handle_destroy(portid_t port_id, · line 2876

Quoted 6 lines
app/test-pmd/config.c +1 -2
 			job->type = QUEUE_JOB_TYPE_ACTION_DESTROY;
 			job->pia = pia;
 
-			if (pia->handle &&
-			    rte_flow_async_action_handle_destroy(port_id,
+			if (rte_flow_async_action_handle_destroy(port_id,

Why 'pia->handle' check removed, was it unnecessary to check it at first place?

This seems already discussed and agreed in other thread, so proceeding.

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