[ovs-dev] [PATCH 07/14] in-band: Fix memory leak in get_remote_mac().

Justin Pettit jpettit at nicira.com
Thu Apr 15 22:44:16 UTC 2010


Nice catch.  Thank you.

--Justin


On Apr 8, 2010, at 5:07 PM, Ben Pfaff wrote:

> If the call to netdev_open_default() failed then next_hop_dev was not
> freed, but it should be.
> ---
> ofproto/in-band.c |    3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/ofproto/in-band.c b/ofproto/in-band.c
> index 767f3e2..219ab8d 100644
> --- a/ofproto/in-band.c
> +++ b/ofproto/in-band.c
> @@ -279,10 +279,12 @@ get_remote_mac(struct in_band *ib)
>                              "to controller "IP_FMT"): %s",
>                              next_hop_dev, IP_ARGS(&ib->controller_ip),
>                              strerror(retval));
> +                free(next_hop_dev);
>                 ib->next_remote_refresh = now + 1;
>                 return NULL;
>             }
>         }
> +        free(next_hop_dev);
> 
>         /* Look up the MAC address of the next-hop IP address. */
>         retval = netdev_arp_lookup(ib->remote_netdev, r_in4.s_addr,
> @@ -292,7 +294,6 @@ get_remote_mac(struct in_band *ib)
>                         IP_ARGS(&r_in4.s_addr), strerror(retval));
>         }
>         have_mac = !eth_addr_is_zero(ib->remote_mac);
> -        free(next_hop_dev);
>         if (have_mac
>             && !eth_addr_equals(ib->last_remote_mac, ib->remote_mac)) {
>             VLOG_DBG("remote MAC address changed from "ETH_ADDR_FMT" to "
> -- 
> 1.6.6.1
> 
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org





More information about the dev mailing list