ofproto-dpif-xlate: Fix memory leak in is_neighbor_reply_correct() function
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
Fixes: ("userspace: Enable non-bridge port as tunnel endpoint.")
@@ -4027,13 +4027,17 @@ 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)) {
+ if (!error) {
+ ret = is_neighbor_reply_matched(flow, ip_addr);
+ free(ip_addr);
+ free(mask);
+ if (ret) {
/* Found a match. */
- ret = true;
break;
}
}
}
+ }
return ret;
}
