diff mbox series

[ovs-dev,2/7] ofproto-dpif-xlate: Fix memory leak in xlate_generic_encap_action().

Message ID 8454c331795588a8d87dd3b1705d06142b6f2e2d.1749133911.git.echaudro@redhat.com
State Accepted
Commit ce20ca0631821503775fe6012013aa5fc62a6483
Delegated to: aaron conole
Headers show
Series Various Coverity fixes. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed

Commit Message

Eelco Chaudron June 5, 2025, 2:51 p.m. UTC
This is not a real issue, as the initializer function,
rewrite_flow_push_nsh(), ensures it returns NULL on error.
However, cleaning this up improves code clarity and resolves
a Coverity warning about a potential memory leak.

Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
---
 ofproto/ofproto-dpif-xlate.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Aaron Conole June 5, 2025, 4:39 p.m. UTC | #1
Eelco Chaudron via dev <ovs-dev@openvswitch.org> writes:

> This is not a real issue, as the initializer function,
> rewrite_flow_push_nsh(), ensures it returns NULL on error.
> However, cleaning this up improves code clarity and resolves
> a Coverity warning about a potential memory leak.
>
> Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
> ---

Acked-by: Aaron Conole <aconole@redhat.com>
Eelco Chaudron June 10, 2025, 8:24 p.m. UTC | #2
On 5 Jun 2025, at 18:39, Aaron Conole wrote:

> Eelco Chaudron via dev <ovs-dev@openvswitch.org> writes:
>
>> This is not a real issue, as the initializer function,
>> rewrite_flow_push_nsh(), ensures it returns NULL on error.
>> However, cleaning this up improves code clarity and resolves
>> a Coverity warning about a potential memory leak.
>>
>> Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
>> ---
>
> Acked-by: Aaron Conole <aconole@redhat.com>

Thanks for the review Aaron! Applied to main.

//Eelco
diff mbox series

Patch

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index c8c3b1210..2c8197fb7 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -7055,6 +7055,8 @@  xlate_generic_encap_action(struct xlate_ctx *ctx,
         /* The actual encap datapath action will be generated at next commit. */
         ctx->pending_encap = true;
         ctx->encap_data = encap_data;
+    } else {
+        ofpbuf_delete(encap_data);
     }
 }