diff mbox

[ovs-dev] ofproto-dpif-xlate: Fix memory leak in execute_controller_action.

Message ID 1474385746-79700-1-git-send-email-rmoats@us.ibm.com
State Accepted
Headers show

Commit Message

Ryan Moats Sept. 20, 2016, 3:35 p.m. UTC
commit df70a7731 ("ofproto-dpif-xlate: Allow translating
without side-effects.") created a memory leak by removing the
dp_packet_delete statement in execute_controller_action that
freed the earlier cloned packet.  This commit restores this
statement to the end of the method.

This issue is only seen in the master branch.

Fixes: df70a7731 ("ofproto-dpif-xlate: Allow translating without side-effects.")
Signed-off-by: Ryan Moats <rmoats@us.ibm.com>
---
 ofproto/ofproto-dpif-xlate.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Ben Pfaff Sept. 20, 2016, 4:59 p.m. UTC | #1
On Tue, Sep 20, 2016 at 10:35:46AM -0500, Ryan Moats wrote:
> commit df70a7731 ("ofproto-dpif-xlate: Allow translating
> without side-effects.") created a memory leak by removing the
> dp_packet_delete statement in execute_controller_action that
> freed the earlier cloned packet.  This commit restores this
> statement to the end of the method.
> 
> This issue is only seen in the master branch.
> 
> Fixes: df70a7731 ("ofproto-dpif-xlate: Allow translating without side-effects.")
> Signed-off-by: Ryan Moats <rmoats@us.ibm.com>

Thanks, applied to master.
Jarno Rajahalme Sept. 20, 2016, 5:39 p.m. UTC | #2
> On Sep 20, 2016, at 8:35 AM, Ryan Moats <rmoats@us.ibm.com> wrote:
> 
> commit df70a7731 ("ofproto-dpif-xlate: Allow translating
> without side-effects.") created a memory leak by removing the
> dp_packet_delete statement in execute_controller_action that
> freed the earlier cloned packet.  This commit restores this
> statement to the end of the method.
> 
> This issue is only seen in the master branch.
> 

Thanks for the fix. I missed the fact that while the packet data is unconditionally taken away from the ‘packet’, the struct dp_packet itself still needs to be freed.

  Jarno

> Fixes: df70a7731 ("ofproto-dpif-xlate: Allow translating without side-effects.")
> Signed-off-by: Ryan Moats <rmoats@us.ibm.com>
> ---
> ofproto/ofproto-dpif-xlate.c | 2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
> index f17cb79..71ffca0 100644
> --- a/ofproto/ofproto-dpif-xlate.c
> +++ b/ofproto/ofproto-dpif-xlate.c
> @@ -3648,6 +3648,8 @@ execute_controller_action(struct xlate_ctx *ctx, int len,
>         entry->controller.ofproto = ctx->xbridge->ofproto;
>         entry->controller.am = am;
>     }
> +
> +    dp_packet_delete(packet);
> }
> 
> static void
> -- 
> 2.7.0
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
diff mbox

Patch

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index f17cb79..71ffca0 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -3648,6 +3648,8 @@  execute_controller_action(struct xlate_ctx *ctx, int len,
         entry->controller.ofproto = ctx->xbridge->ofproto;
         entry->controller.am = am;
     }
+
+    dp_packet_delete(packet);
 }
 
 static void