Skip to content

Commit eaa7ce6

Browse files
ilanpeer2jmberg-intel
authored andcommitted
wifi: mac80211_hwsim: Fix possible NULL dereference
The 'vif' pointer in the Tx information might be NULL, e.g., in case of injected frames etc. and is not checked in all paths. Fix it. While at it, also directly use the local 'vif' pointer. Fixes: a37a6f5 ("wifi: mac80211_hwsim: Add simulation support for NAN device") Signed-off-by: Ilan Peer <ilan.peer@intel.com> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/linux-wireless/aNJUlyIiSTW9zZdr@stanley.mountain Reviewed-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20251110140128.ec00ae795a32.I9c65659b52434189d8b2ba06710d482669a3887a@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 7fe0d21 commit eaa7ce6

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

drivers/net/wireless/virtual/mac80211_hwsim.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,8 +2003,14 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
20032003
struct ieee80211_sta *sta = control->sta;
20042004
struct ieee80211_bss_conf *bss_conf;
20052005

2006+
/* This can happen in case of monitor injection */
2007+
if (!vif) {
2008+
ieee80211_free_txskb(hw, skb);
2009+
return;
2010+
}
2011+
20062012
if (link != IEEE80211_LINK_UNSPECIFIED) {
2007-
bss_conf = rcu_dereference(txi->control.vif->link_conf[link]);
2013+
bss_conf = rcu_dereference(vif->link_conf[link]);
20082014
if (sta)
20092015
link_sta = rcu_dereference(sta->link[link]);
20102016
} else {
@@ -2065,13 +2071,13 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
20652071
return;
20662072
}
20672073

2068-
if (txi->control.vif)
2069-
hwsim_check_magic(txi->control.vif);
2074+
if (vif)
2075+
hwsim_check_magic(vif);
20702076
if (control->sta)
20712077
hwsim_check_sta_magic(control->sta);
20722078

20732079
if (ieee80211_hw_check(hw, SUPPORTS_RC_TABLE))
2074-
ieee80211_get_tx_rates(txi->control.vif, control->sta, skb,
2080+
ieee80211_get_tx_rates(vif, control->sta, skb,
20752081
txi->control.rates,
20762082
ARRAY_SIZE(txi->control.rates));
20772083

0 commit comments

Comments
 (0)