Search Linux Wireless

Re: [PATCH] iw:Fix memory leak if nla_put fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2015-11-27 at 15:07 +0530, Rahul Jain wrote:
> 
> @@ -124,7 +124,8 @@ static int handle_coalesce_enable(struct
> nl80211_state *state,
>  					nla_nest_end(msg, nl_pat);
>  					free(mask);
>  					free(pat);
> -
> +					pat = NULL;
> +					mask = NULL;

I'd prefer to keep the blank line.

> +	if (pat)
> +		free(pat);

free(NULL) is valid and a no-op.

> -			NLA_PUT(msg, NL80211_WOWLAN_TCP_WAKE_MASK,
> -				DIV_ROUND_UP(patlen, 8), mask);
> -			NLA_PUT(msg,
> NL80211_WOWLAN_TCP_WAKE_PAYLOAD,
> -				patlen, pat);
> +			if (nla_put(msg,
> NL80211_WOWLAN_TCP_WAKE_MASK,
> +				DIV_ROUND_UP(patlen, 8), mask) < 0)
> {
> +				free(mask);
> +				free(pat);
> +				mask = NULL;
> +				pat = NULL;
> +				goto nla_put_failure;
> +			}
> +			if (nla_put(msg,
> NL80211_WOWLAN_TCP_WAKE_PAYLOAD,
> +				patlen, pat) < 0){
> +				free(pat);
> +				free(mask);
> +				pat = NULL;
> +				mask = NULL;
> +				goto nla_put_failure;
> +			}

I don't understand - you also updated the nla_put_failure label to free
it.

>  			free(mask);
>  			free(pat);

seems like you need NULL here though.

johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux