diff mbox series

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

Message ID 1570090559-17150-1-git-send-email-damjan.skvarc@gmail.com
State Accepted
Headers show
Series [ovs-dev,1/1] ofproto-dpif-xlate: fixed memory leak in is_neighbor_reply_correct() function | expand

Commit Message

Damijan Skvarc Oct. 3, 2019, 8:15 a.m. UTC
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@gmail.com>
---
 ofproto/ofproto-dpif-xlate.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Ben Pfaff Oct. 3, 2019, 1:30 p.m. UTC | #1
On Thu, Oct 03, 2019 at 10:15:59AM +0200, Damijan Skvarc wrote:
> 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@gmail.com>

Thank you.  I applied this to master.
diff mbox series

Patch

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;
+                }
             }
         }
     }