diff mbox

[ovs-dev,3/3] ovs-ofctl: Fix memory leak in bundle_print_errors().

Message ID 1479764561-16741-3-git-send-email-yihung.wei@gmail.com
State Accepted
Delegated to: Daniele Di Proietto
Headers show

Commit Message

Yi-Hung Wei Nov. 21, 2016, 9:42 p.m. UTC
In testcase "ofproto - bundle group mod with mod and add_or_mod command",
valgrind reports a memory leak with the following call stack.
    xmalloc (util.c:112)
    ofpbuf_resize__ (ofpbuf.c:246)
    ofpbuf_push_uninit (ofpbuf.c:436)
    ofpbuf_push (ofpbuf.c:459)
    ofperr_decode_msg (ofp-errors.c:332)
    bundle_print_errors (ovs-ofctl.c:692)
    bundle_transact.constprop.25 (ovs-ofctl.c:728)
    bundle_group_mod__ (ovs-ofctl.c:2663)
    ofctl_group_mod__ (ovs-ofctl.c:2681)
    ofctl_group_mod (ovs-ofctl.c:2736)
    ovs_cmdl_run_command__ (command-line.c:115)
    main (ovs-ofctl.c:151)

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
---
 utilities/ovs-ofctl.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Ben Pfaff Nov. 22, 2016, 6:58 p.m. UTC | #1
On Mon, Nov 21, 2016 at 01:42:41PM -0800, Yi-Hung Wei wrote:
> In testcase "ofproto - bundle group mod with mod and add_or_mod command",
> valgrind reports a memory leak with the following call stack.
>     xmalloc (util.c:112)
>     ofpbuf_resize__ (ofpbuf.c:246)
>     ofpbuf_push_uninit (ofpbuf.c:436)
>     ofpbuf_push (ofpbuf.c:459)
>     ofperr_decode_msg (ofp-errors.c:332)
>     bundle_print_errors (ovs-ofctl.c:692)
>     bundle_transact.constprop.25 (ovs-ofctl.c:728)
>     bundle_group_mod__ (ovs-ofctl.c:2663)
>     ofctl_group_mod__ (ovs-ofctl.c:2681)
>     ofctl_group_mod (ovs-ofctl.c:2736)
>     ovs_cmdl_run_command__ (command-line.c:115)
>     main (ovs-ofctl.c:151)
> 
> Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>

Thanks for the bug fixes!  I applied these to master and backported the
relevant ones to branch-2.6.  It appears that none of these bugs existed
before 2.6.
diff mbox

Patch

diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 29b324b..7f5bb61 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -714,6 +714,7 @@  bundle_print_errors(struct ovs_list *errors, struct ovs_list *requests)
             fprintf(stderr, "Error %s for: ", ofperr_get_name(ofperr));
             ofp_print(stderr, ofp_msg, msg_len, verbosity + 1);
         }
+        ofpbuf_uninit(&payload);
         free(error);
     }
     fflush(stderr);