From: Larry Finger Date: Sat, 25 Jun 2016 18:37:47 +0000 (-0500) Subject: rtlwifi: rtl8821ae: Fix potential race condition X-Git-Tag: v4.8-rc1~140^2~121^2~41 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=300c32ca84f5006ccbbf37f5207b6311aeccc5c8;p=platform%2Fkernel%2Flinux-exynos.git rtlwifi: rtl8821ae: Fix potential race condition Flag rfchange_inprogress in struct rtl_ps_ctl is protected by a spinlock in most routines but not in rtl8821ae_dm_watchdog() which could lead to a race condition. The necessary locking to prevent this condition is added. Reported-by: Pavel Andrianov Signed-off-by: Larry Finger Cc: Pavel Andrianov Signed-off-by: Kalle Valo --- diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c index 69de835..03e08cb 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c @@ -2949,6 +2949,7 @@ void rtl8821ae_dm_watchdog(struct ieee80211_hw *hw) if (ppsc->p2p_ps_info.p2p_ps_mode) fw_ps_awake = false; + spin_lock(&rtlpriv->locks.rf_ps_lock); if ((ppsc->rfpwr_state == ERFON) && ((!fw_current_inpsmode) && fw_ps_awake) && (!ppsc->rfchange_inprogress)) { @@ -2967,6 +2968,7 @@ void rtl8821ae_dm_watchdog(struct ieee80211_hw *hw) rtl8821ae_dm_check_txpower_tracking_thermalmeter(hw); rtl8821ae_dm_iq_calibrate(hw); } + spin_unlock(&rtlpriv->locks.rf_ps_lock); rtlpriv->dm.dbginfo.num_qry_beacon_pkt = 0; RT_TRACE(rtlpriv, COMP_DIG, DBG_DMESG, "\n");