[ovs-dev] [PATCH 1/1] ofproto-dpif-xlate: fixed memory leak in is_neighbor_reply_correct() function

Damijan Skvarc damjan.skvarc at gmail.com
Thu Oct 3 08:15:59 UTC 2019


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.

Signed-off-by: Damijan Skvarc <damjan.skvarc at gmail.com>
---
 ofproto/ofproto-dpif-xlate.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 9c31c06..44f856d 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -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;
+                }
             }
         }
     }
-- 
2.7.4



More information about the dev mailing list