Skip to content

Commit 4130c67

Browse files
Miriam-Racheljmberg-intel
authored andcommitted
wifi: iwlwifi: mvm: check vif for NULL/ERR_PTR before dereference
iwl_mvm_get_bss_vif might return a NULL or ERR_PTR. Some of the callers check only the NULL case, and some doesn't check at all. Some of the callers even have a pointer to the mvmvif of the bss vif, so we don't even need to call this function, and can simply get the vif from mvmvif. Do it for those cases, and for the others - properly check if IS_ERR_OR_NULL Fixes: ec0d43d ("wifi: iwlwifi: mvm: Activate EMLSR based on traffic volume") Signed-off-by: Miri Korenblit <[email protected]> Link: https://patch.msgid.link/20240703064027.a661f8c65aac.I45cf09b01af8ee3d55828863958ead741ea43b7f@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent 28e02bc commit 4130c67

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,7 +1656,8 @@ static void iwl_mvm_prevent_esr_done_wk(struct wiphy *wiphy,
16561656
struct iwl_mvm_vif *mvmvif =
16571657
container_of(wk, struct iwl_mvm_vif, prevent_esr_done_wk.work);
16581658
struct iwl_mvm *mvm = mvmvif->mvm;
1659-
struct ieee80211_vif *vif = iwl_mvm_get_bss_vif(mvm);
1659+
struct ieee80211_vif *vif =
1660+
container_of((void *)mvmvif, struct ieee80211_vif, drv_priv);
16601661

16611662
mutex_lock(&mvm->mutex);
16621663
iwl_mvm_unblock_esr(mvm, vif, IWL_MVM_ESR_BLOCKED_PREVENTION);
@@ -1682,7 +1683,8 @@ static void iwl_mvm_unblock_esr_tpt(struct wiphy *wiphy, struct wiphy_work *wk)
16821683
struct iwl_mvm_vif *mvmvif =
16831684
container_of(wk, struct iwl_mvm_vif, unblock_esr_tpt_wk);
16841685
struct iwl_mvm *mvm = mvmvif->mvm;
1685-
struct ieee80211_vif *vif = iwl_mvm_get_bss_vif(mvm);
1686+
struct ieee80211_vif *vif =
1687+
container_of((void *)mvmvif, struct ieee80211_vif, drv_priv);
16861688

16871689
mutex_lock(&mvm->mutex);
16881690
iwl_mvm_unblock_esr(mvm, vif, IWL_MVM_ESR_BLOCKED_TPT);

drivers/net/wireless/intel/iwlwifi/mvm/ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static void iwl_mvm_rx_esr_mode_notif(struct iwl_mvm *mvm,
153153
struct ieee80211_vif *vif = iwl_mvm_get_bss_vif(mvm);
154154

155155
/* FW recommendations is only for entering EMLSR */
156-
if (!vif || iwl_mvm_vif_from_mac80211(vif)->esr_active)
156+
if (IS_ERR_OR_NULL(vif) || iwl_mvm_vif_from_mac80211(vif)->esr_active)
157157
return;
158158

159159
if (le32_to_cpu(notif->action) == ESR_RECOMMEND_ENTER)

drivers/net/wireless/intel/iwlwifi/mvm/rx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ static void iwl_mvm_update_esr_mode_tpt(struct iwl_mvm *mvm)
966966

967967
lockdep_assert_held(&mvm->mutex);
968968

969-
if (!bss_vif)
969+
if (IS_ERR_OR_NULL(bss_vif))
970970
return;
971971

972972
mvmvif = iwl_mvm_vif_from_mac80211(bss_vif);

0 commit comments

Comments
 (0)