]> git.proxmox.com Git - mirror_ovs.git/commitdiff
ofproto-dpif-xlate: Fix memory leak in is_neighbor_reply_correct() function
authorDamijan Skvarc <damjan.skvarc@gmail.com>
Thu, 3 Oct 2019 08:15:59 +0000 (10:15 +0200)
committerBen Pfaff <blp@ovn.org>
Thu, 3 Oct 2019 13:30:01 +0000 (06:30 -0700)
Memory leak happens while calling netdev_get_addr_list() function. This
function allocates memory for ip_addr and mask output arguments, but
this memory is never freed.

CC: Yifeng Sun <pkusunyifeng@gmail.com>
Fixes: dc0bd12f5b04 ("userspace: Enable non-bridge port as tunnel endpoint.")
Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
ofproto/ofproto-dpif-xlate.c

index 9c31c06af718d106b008816b006e97e032897a86..44f856dcab09757f0deceb831c65be2dcad0f303 100644 (file)
@@ -4027,10 +4027,14 @@ is_neighbor_reply_correct(const struct xlate_ctx *ctx, const struct flow *flow)
         HMAP_FOR_EACH (port, ofp_node, &ctx->xbridge->xports) {
             error = netdev_get_addr_list(port->netdev, &ip_addr,
                                          &mask, &n_in6);
-            if (!error && is_neighbor_reply_matched(flow, ip_addr)) {
-                /* Found a match. */
-                ret = true;
-                break;
+            if (!error) {
+                ret = is_neighbor_reply_matched(flow, ip_addr);
+                free(ip_addr);
+                free(mask);
+                if (ret) {
+                   /* Found a match. */
+                   break;
+                }
             }
         }
     }