RE: [PATCH] wifi: iwlwifi: Fix uninitialized variable with __free()
From: Korenblit, Miriam Rachel
Date: Wed Mar 12 2025 - 15:32:29 EST
> -----Original Message-----
> From: Markus Elfring <Markus.Elfring@xxxxxx>
> Sent: Wednesday, 12 March 2025 17:42
> To: Dan Carpenter <dan.carpenter@xxxxxxxxxx>; linux-wireless@xxxxxxxxxxxxxxx
> Cc: kernel-janitors@xxxxxxxxxxxxxxx; LKML <linux-kernel@xxxxxxxxxxxxxxx>;
> Anjaneyulu, Pagadala Yesu <pagadala.yesu.anjaneyulu@xxxxxxxxx>; Stern,
> Avraham <avraham.stern@xxxxxxxxx>; Gabay, Daniel <daniel.gabay@xxxxxxxxx>;
> Grumbach, Emmanuel <emmanuel.grumbach@xxxxxxxxx>; Jeff Johnson
> <jeff.johnson@xxxxxxxxxxxxxxxx>; Berg, Johannes <johannes.berg@xxxxxxxxx>;
> Korenblit, Miriam Rachel <miriam.rachel.korenblit@xxxxxxxxx>; Ben Shimol,
> Yedidya <yedidya.ben.shimol@xxxxxxxxx>
> Subject: Re: [PATCH] wifi: iwlwifi: Fix uninitialized variable with __free()
>
> …
> > +++ b/drivers/net/wireless/intel/iwlwifi/mld/debugfs.c
> > @@ -556,8 +556,8 @@ iwl_dbgfs_vif_twt_setup_write(struct iwl_mld *mld,
> char *buf, size_t count,
> > };
> > struct ieee80211_vif *vif = data;
> > struct iwl_mld_vif *mld_vif = iwl_mld_vif_from_mac80211(vif);
> > + struct iwl_dhc_cmd *cmd __free(kfree) = NULL;
> > struct iwl_dhc_twt_operation *dhc_twt_cmd;
> > - struct iwl_dhc_cmd *cmd __free(kfree);
> …
>
> Can it be recommended to reduce the scope for the affected local variable
> instead?
> https://elixir.bootlin.com/linux/v6.14-rc6/source/include/linux/cleanup.h#L129-
> L133
As said in reply to Jeff's review -
This is recommended if you have multiple __kfree variables (and the order of freeing matters)
Or if there is a guard() later in the function.
This function is not the case and will probably never be since the entire function is running under the relevant lock.
Miri