ebb439
From b2758cd591c6b46426f9b21540c88b2c3ef9b1d5 Mon Sep 17 00:00:00 2001
ebb439
From: Ilya Maximets <i.maximets@ovn.org>
ebb439
Date: Fri, 20 Nov 2020 01:17:15 +0100
ebb439
Subject: [PATCH 07/16] ofctrl: Fix leak of meter mod bands.
ebb439
ebb439
'parse_ofp_meter_mod_str' allocates space for meter.bands that
ebb439
should be freed.
ebb439
ebb439
  Direct leak of 448 byte(s) in 7 object(s) allocated from:
ebb439
    #0 0x52100f in malloc (/controller/ovn-controller+0x52100f)
ebb439
    #1 0x7523a6 in xmalloc /lib/util.c:138:15
ebb439
    #2 0x6fd079 in ofpbuf_init /lib/ofpbuf.c:123:26
ebb439
    #3 0x6cba27 in parse_ofp_meter_mod_str /lib/ofp-meter.c:779:5
ebb439
    #4 0x5705b8 in add_meter_string /controller/ofctrl.c:1674:19
ebb439
    #5 0x56f736 in ofctrl_put /controller/ofctrl.c:2105:13
ebb439
    #6 0x59aebb in main /controller/ovn-controller.c:2627:25
ebb439
    #7 0x7f07873251a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
ebb439
ebb439
CC: Guoshuai Li <ligs@dtdream.com>
ebb439
Fixes: c25094b3884d ("ovn: OVN Support QoS meter")
ebb439
Acked-by: Dumitru Ceara <dceara@redhat.com>
ebb439
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
ebb439
Signed-off-by: Numan Siddique <numans@ovn.org>
ebb439
---
ebb439
 controller/ofctrl.c | 1 +
ebb439
 1 file changed, 1 insertion(+)
ebb439
ebb439
diff --git a/controller/ofctrl.c b/controller/ofctrl.c
ebb439
index 79529d13c..c1bbc589e 100644
ebb439
--- a/controller/ofctrl.c
ebb439
+++ b/controller/ofctrl.c
ebb439
@@ -1675,6 +1675,7 @@ add_meter_string(struct ovn_extend_table_info *m_desired,
ebb439
                                           &usable_protocols);
ebb439
     if (!error) {
ebb439
         add_meter_mod(&mm, msgs);
ebb439
+        free(mm.meter.bands);
ebb439
     } else {
ebb439
         static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
ebb439
         VLOG_ERR_RL(&rl, "new meter %s %s", error, meter_string);
ebb439
-- 
ebb439
2.28.0
ebb439