diff mbox

[ovs-dev,v2,2/3] ovs-ofctl: fix memory leak reported by valgrind

Message ID 1451953121-23921-2-git-send-email-u9012063@gmail.com
State Accepted
Headers show

Commit Message

William Tu Jan. 5, 2016, 12:18 a.m. UTC
Test case: ovs-ofctl replace-flows with --bundle(376) reports two leaks:
    ofpbuf_new(ofpbuf.c:151)
    ofpraw_alloc_xid(ofp-msgs.c:533)
    ofpraw_alloc(ofp-msgs.c:525)
    ofputil_encode_flow_mod(ofp-util.c:2290)
    bundle_flow_mod__(ovs-ofctl.c:1312)
    ofctl_flow_mod__(ovs-ofctl.c:1331)
    ofctl_flow_mod_file.isra.13(ovs-ofctl.c:1365)
    ovs_cmdl_run_command(command-line.c:121)
    main(ovs-ofctl.c:135)
and
    ofpraw_alloc(ofp-msgs.c:525)
    ofputil_encode_flow_mod(ofp-util.c:2290)
    fte_make_flow_mod(ovs-ofctl.c:2936)
    ofctl_replace_flows(ovs-ofctl.c:2981)
    ovs_cmdl_run_command(command-line.c:121)
    main(ovs-ofctl.c:135)

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Co-authored-by: Daniele Di Proietto <diproiettod@vmware.com>
---
 utilities/ovs-ofctl.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Ben Pfaff Jan. 5, 2016, 12:55 a.m. UTC | #1
On Mon, Jan 04, 2016 at 04:18:40PM -0800, William Tu wrote:
> Test case: ovs-ofctl replace-flows with --bundle(376) reports two leaks:
>     ofpbuf_new(ofpbuf.c:151)
>     ofpraw_alloc_xid(ofp-msgs.c:533)
>     ofpraw_alloc(ofp-msgs.c:525)
>     ofputil_encode_flow_mod(ofp-util.c:2290)
>     bundle_flow_mod__(ovs-ofctl.c:1312)
>     ofctl_flow_mod__(ovs-ofctl.c:1331)
>     ofctl_flow_mod_file.isra.13(ovs-ofctl.c:1365)
>     ovs_cmdl_run_command(command-line.c:121)
>     main(ovs-ofctl.c:135)
> and
>     ofpraw_alloc(ofp-msgs.c:525)
>     ofputil_encode_flow_mod(ofp-util.c:2290)
>     fte_make_flow_mod(ovs-ofctl.c:2936)
>     ofctl_replace_flows(ovs-ofctl.c:2981)
>     ovs_cmdl_run_command(command-line.c:121)
>     main(ovs-ofctl.c:135)
> 
> Signed-off-by: William Tu <u9012063@gmail.com>
> Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
> Co-authored-by: Daniele Di Proietto <diproiettod@vmware.com>

Thanks, applied to master.
diff mbox

Patch

diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 4ab83b9..70f1440 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -1316,6 +1316,7 @@  bundle_flow_mod__(const char *remote, struct ofputil_flow_mod *fms,
     }
 
     bundle_transact(vconn, &requests, OFPBF_ORDERED | OFPBF_ATOMIC);
+    ofpbuf_list_delete(&requests);
     vconn_close(vconn);
 }
 
@@ -2981,6 +2982,8 @@  ofctl_replace_flows(struct ovs_cmdl_context *ctx)
     } else {
         transact_multiple_noreply(vconn, &requests);
     }
+
+    ofpbuf_list_delete(&requests);
     vconn_close(vconn);
 
     fte_free_all(&tables);