[ovs-dev] [PATCH v2 ovn 1/2] ovn-northd: Fix memory leak in build_lswitch_rport_arp_req_flows().

Dumitru Ceara dceara at redhat.com
Wed Jul 8 15:02:53 UTC 2020


The error string returned by ip_parse_masked() and ipv6_parse_masked() was
not freed leading to a memory leak.

Fixes: 32f5ebb06226 ("ovn-northd: Limit ARP/ND broadcast domain whenever possible.")
Signed-off-by: Dumitru Ceara <dceara at redhat.com>
---
 northd/ovn-northd.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
index ddfcebe..4c23158 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -6243,13 +6243,17 @@ build_lswitch_rport_arp_req_flows(struct ovn_port *op,
         struct in6_addr ipv6;
         struct in6_addr mask_v6;
 
-        if (ip_parse_masked(nat->external_ip, &ip, &mask)) {
-            if (!ipv6_parse_masked(nat->external_ip, &ipv6, &mask_v6)) {
+        char *error = ip_parse_masked(nat->external_ip, &ip, &mask);
+        if (error) {
+            free(error);
+            error = ipv6_parse_masked(nat->external_ip, &ipv6, &mask_v6);
+            if (!error) {
                 sset_add(&all_ips_v6, nat->external_ip);
             }
         } else {
             sset_add(&all_ips_v4, nat->external_ip);
         }
+        free(error);
     }
 
     if (!sset_is_empty(&all_ips_v4)) {



More information about the dev mailing list