[lvc-project] [PATCH] wifi: mac80211_hwsim: do not ignore the value returned by nla_put_u32()

Johannes Berg johannes at sipsolutions.net
Tue Aug 22 15:15:45 MSK 2023


On Mon, 2023-08-14 at 12:21 +0300, Dmitry Antipov wrote:
> In 'mac80211_hwsim_vendor_cmd_test()', do not ignore the value
> returned by 'nla_put_u32'. This follows commit b970ac68e0c4
> ("wifi: mac80211_hwsim: check the return value of nla_put_u32").
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Dmitry Antipov <dmantipov at yandex.ru>
> ---
>  drivers/net/wireless/virtual/mac80211_hwsim.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/virtual/mac80211_hwsim.c b/drivers/net/wireless/virtual/mac80211_hwsim.c
> index f446fd0e8cd0..2a3393a47bf2 100644
> --- a/drivers/net/wireless/virtual/mac80211_hwsim.c
> +++ b/drivers/net/wireless/virtual/mac80211_hwsim.c
> @@ -597,9 +597,9 @@ static int mac80211_hwsim_vendor_cmd_test(struct wiphy *wiphy,
>  	/* skb_put() or nla_put() will fill up data within
>  	 * NL80211_ATTR_VENDOR_DATA
>  	 */
> -	nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_TEST, val + 2);
> +	err = nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_TEST, val + 2);
>  
> -	return cfg80211_vendor_cmd_reply(skb);
> +	return err ? err : cfg80211_vendor_cmd_reply(skb);
> 

You can use ?: here, but more importantly, this introduces a memory
leak.

johannes



More information about the lvc-project mailing list