From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> Date: Wed, 19 Apr 2023 18:35:55 +0200 The address of a data structure member was determined before a corresponding null pointer check in the implementation of the function “il_set_ht_add_station”. Thus avoid the risk for undefined behaviour by moving the assignment for the variable “sta_ht_inf” behind the null pointer check. This issue was detected by using the Coccinelle software. Delete also the jump target “done” by using return statements directly for two if branches. Fixes: 046d2e7c50e3 ("mac80211: prepare sta handling for MLO support") Fixes: e7392364fcd1 ("iwlegacy: indentions and whitespaces") Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> --- drivers/net/wireless/intel/iwlegacy/common.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c index 96002121bb8b..8f6fd17b02a8 100644 --- a/drivers/net/wireless/intel/iwlegacy/common.c +++ b/drivers/net/wireless/intel/iwlegacy/common.c @@ -1863,11 +1863,15 @@ EXPORT_SYMBOL(il_send_add_sta); static void il_set_ht_add_station(struct il_priv *il, u8 idx, struct ieee80211_sta *sta) { - struct ieee80211_sta_ht_cap *sta_ht_inf = &sta->deflink.ht_cap; + struct ieee80211_sta_ht_cap *sta_ht_inf; __le32 sta_flags; - if (!sta || !sta_ht_inf->ht_supported) - goto done; + if (!sta) + return; + + sta_ht_inf = &sta->deflink.ht_cap; + if (!sta_ht_inf->ht_supported) + return; D_ASSOC("spatial multiplexing power save mode: %s\n", (sta->deflink.smps_mode == IEEE80211_SMPS_STATIC) ? "static" : @@ -1906,8 +1910,6 @@ il_set_ht_add_station(struct il_priv *il, u8 idx, struct ieee80211_sta *sta) sta_flags &= ~STA_FLG_HT40_EN_MSK; il->stations[idx].sta.station_flags = sta_flags; -done: - return; } /* -- 2.40.0