[lxc-devel] [PATCH 4/4] coverity: fix leak when ipv6 gw is auto

Serge Hallyn serge.hallyn at ubuntu.com
Fri May 3 16:27:54 UTC 2013


Quoting Dwight Engen (dwight.engen at oracle.com):
> Signed-off-by: Dwight Engen <dwight.engen at oracle.com>

Thanks.  To prevent future snafus it might be worth declaring gw just
in that block, but

Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>

> ---
>  src/lxc/confile.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/src/lxc/confile.c b/src/lxc/confile.c
> index d0a404f..fbae861 100644
> --- a/src/lxc/confile.c
> +++ b/src/lxc/confile.c
> @@ -782,12 +782,6 @@ static int config_network_ipv6_gateway(const char *key, const char *value,
>  	if (!netdev)
>  		return -1;
>  
> -	gw = malloc(sizeof(*gw));
> -	if (!gw) {
> -		SYSERROR("failed to allocate ipv6 gateway address");
> -		return -1;
> -	}
> -
>  	if (!value) {
>  		ERROR("no ipv6 gateway address specified");
>  		return -1;
> @@ -797,6 +791,12 @@ static int config_network_ipv6_gateway(const char *key, const char *value,
>  		netdev->ipv6_gateway = NULL;
>  		netdev->ipv6_gateway_auto = true;
>  	} else {
> +		gw = malloc(sizeof(*gw));
> +		if (!gw) {
> +			SYSERROR("failed to allocate ipv6 gateway address");
> +			return -1;
> +		}
> +
>  		if (!inet_pton(AF_INET6, value, gw)) {
>  			SYSERROR("invalid ipv6 gateway address: %s", value);
>  			free(gw);
> -- 
> 1.8.1.4
> 
> 
> ------------------------------------------------------------------------------
> Get 100% visibility into Java/.NET code with AppDynamics Lite
> It's a free troubleshooting tool designed for production
> Get down to code-level detail for bottlenecks, with <2% overhead.
> Download for free and get started troubleshooting in minutes.
> http://p.sf.net/sfu/appdyn_d2d_ap2
> _______________________________________________
> Lxc-devel mailing list
> Lxc-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel




More information about the lxc-devel mailing list