diff mbox

[ovs-dev,1/8] ofproto: Fix memory leak in handle_tlv_table_mod()

Message ID 1491601426-77274-1-git-send-email-yihung.wei@gmail.com
State Accepted
Headers show

Commit Message

Yi-Hung Wei April 7, 2017, 9:43 p.m. UTC
In testcase "tunnel - Geneve metadata", valgrind reports a memory leak with
the following call stack.
    xcalloc (util.c:95)
    tun_metadata_alloc (tun-metadata.c:89)
    tun_metadata_table_mod (tun-metadata.c:175)
    handle_tlv_table_mod (ofproto.c:7856)
    handle_openflow__ (ofproto.c:8036)
    handle_openflow (ofproto.c:8098)
    ofconn_run (connmgr.c:1427)
    connmgr_run (connmgr.c:363)
    ofproto_run (ofproto.c:1815)
    bridge_run__ (bridge.c:2915)
    bridge_run (bridge.c:2972)
    main (ovs-vswitchd.c:111)

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
---
 ofproto/ofproto.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Ben Pfaff April 23, 2017, 4:54 p.m. UTC | #1
On Fri, Apr 07, 2017 at 02:43:39PM -0700, Yi-Hung Wei wrote:
> In testcase "tunnel - Geneve metadata", valgrind reports a memory leak with
> the following call stack.
>     xcalloc (util.c:95)
>     tun_metadata_alloc (tun-metadata.c:89)
>     tun_metadata_table_mod (tun-metadata.c:175)
>     handle_tlv_table_mod (ofproto.c:7856)
>     handle_openflow__ (ofproto.c:8036)
>     handle_openflow (ofproto.c:8098)
>     ofconn_run (connmgr.c:1427)
>     connmgr_run (connmgr.c:363)
>     ofproto_run (ofproto.c:1815)
>     bridge_run__ (bridge.c:2915)
>     bridge_run (bridge.c:2972)
>     main (ovs-vswitchd.c:111)
> 
> Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>

Thanks!  I applied this to master.  It looks like it isn't needed for
older branches.
diff mbox

Patch

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 84ea95b0c2a2..e8ba8496ab66 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -7862,6 +7862,8 @@  handle_tlv_table_mod(struct ofconn *ofconn, const struct ofp_header *oh)
         if (!error) {
             ovsrcu_set(&ofproto->metadata_tab, new_tab);
             tun_metadata_postpone_free(old_tab);
+        } else {
+            tun_metadata_free(new_tab);
         }
     }