diff mbox series

[ovs-dev,05/14] ofctrl: Fix leak of meter mod bands.

Message ID 20201120001724.2424494-6-i.maximets@ovn.org
State Accepted
Headers show
Series Pack of fixes for memory leaks. | expand

Commit Message

Ilya Maximets Nov. 20, 2020, 12:17 a.m. UTC
'parse_ofp_meter_mod_str' allocates space for meter.bands that
should be freed.

  Direct leak of 448 byte(s) in 7 object(s) allocated from:
    #0 0x52100f in malloc (/controller/ovn-controller+0x52100f)
    #1 0x7523a6 in xmalloc /lib/util.c:138:15
    #2 0x6fd079 in ofpbuf_init /lib/ofpbuf.c:123:26
    #3 0x6cba27 in parse_ofp_meter_mod_str /lib/ofp-meter.c:779:5
    #4 0x5705b8 in add_meter_string /controller/ofctrl.c:1674:19
    #5 0x56f736 in ofctrl_put /controller/ofctrl.c:2105:13
    #6 0x59aebb in main /controller/ovn-controller.c:2627:25
    #7 0x7f07873251a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

CC: Guoshuai Li <ligs@dtdream.com>
Fixes: c25094b3884d ("ovn: OVN Support QoS meter")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---
 controller/ofctrl.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/controller/ofctrl.c b/controller/ofctrl.c
index 79529d13c..c1bbc589e 100644
--- a/controller/ofctrl.c
+++ b/controller/ofctrl.c
@@ -1675,6 +1675,7 @@  add_meter_string(struct ovn_extend_table_info *m_desired,
                                           &usable_protocols);
     if (!error) {
         add_meter_mod(&mm, msgs);
+        free(mm.meter.bands);
     } else {
         static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
         VLOG_ERR_RL(&rl, "new meter %s %s", error, meter_string);