[ovs-dev] [PATCH 1/3] ovn-northd: Fix memory leak when IPv6 IPAM is in use.

Ben Pfaff blp at ovn.org
Fri Jun 15 23:11:55 UTC 2018


Every iteration of the main loop allocated a new IPAM structure.

Found by inspection.

Signed-off-by: Ben Pfaff <blp at ovn.org>
---
 ovn/northd/ovn-northd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index 74eefc6caeba..344b595ad3c1 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -539,7 +539,9 @@ init_ipam_info_for_datapath(struct ovn_datapath *od)
     const char *ipv6_prefix = smap_get(&od->nbs->other_config, "ipv6_prefix");
 
     if (ipv6_prefix) {
-        od->ipam_info = xzalloc(sizeof *od->ipam_info);
+        if (!od->ipam_info) {
+            od->ipam_info = xzalloc(sizeof *od->ipam_info);
+        }
         od->ipam_info->ipv6_prefix_set = ipv6_parse(
             ipv6_prefix, &od->ipam_info->ipv6_prefix);
     }
-- 
2.16.1



More information about the dev mailing list