rtlwifi: rtl8723ae: Fix potential race condition

Flag rfchange_inprogress in struct rtl_ps_ctl is protected by a spinlock
in most routines but not in rtl8723e_dm_watchdog(), which could
lead to a race condition. The necessary locking to prevent this condition
is added.

Reported-by: Pavel Andrianov <andrianov@ispras.ru>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pavel Andrianov <andrianov@ispras.ru>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
This commit is contained in:
Larry Finger 2016-06-25 13:37:46 -05:00 committed by Kalle Valo
parent 31c2e76c77
commit 4f29b348bd

View File

@ -816,6 +816,7 @@ void rtl8723e_dm_watchdog(struct ieee80211_hw *hw)
if (ppsc->p2p_ps_info.p2p_ps_mode) if (ppsc->p2p_ps_info.p2p_ps_mode)
fw_ps_awake = false; fw_ps_awake = false;
spin_lock(&rtlpriv->locks.rf_ps_lock);
if ((ppsc->rfpwr_state == ERFON) && if ((ppsc->rfpwr_state == ERFON) &&
((!fw_current_inpsmode) && fw_ps_awake) && ((!fw_current_inpsmode) && fw_ps_awake) &&
(!ppsc->rfchange_inprogress)) { (!ppsc->rfchange_inprogress)) {
@ -829,6 +830,7 @@ void rtl8723e_dm_watchdog(struct ieee80211_hw *hw)
rtl8723e_dm_bt_coexist(hw); rtl8723e_dm_bt_coexist(hw);
rtl8723e_dm_check_edca_turbo(hw); rtl8723e_dm_check_edca_turbo(hw);
} }
spin_unlock(&rtlpriv->locks.rf_ps_lock);
if (rtlpriv->btcoexist.init_set) if (rtlpriv->btcoexist.init_set)
rtl_write_byte(rtlpriv, 0x76e, 0xc); rtl_write_byte(rtlpriv, 0x76e, 0xc);
} }