From patchwork Sat Jun 25 18:37:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Finger X-Patchwork-Id: 9198639 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3948F60754 for ; Sat, 25 Jun 2016 18:38:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C9D428522 for ; Sat, 25 Jun 2016 18:38:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 211F328528; Sat, 25 Jun 2016 18:38:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF38E28522 for ; Sat, 25 Jun 2016 18:38:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751789AbcFYSiX (ORCPT ); Sat, 25 Jun 2016 14:38:23 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:33502 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751674AbcFYSiS (ORCPT ); Sat, 25 Jun 2016 14:38:18 -0400 Received: by mail-oi0-f67.google.com with SMTP id w141so24017474oia.0 for ; Sat, 25 Jun 2016 11:38:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=HvEz9CKHzxtzvNoHA5Fmrb6C0KKdJr3425fVCr2E2Q0=; b=ZvLrvZ9q8bNiDXuQDUiQmvi7wV0W4GR0Vfia6b6KpL4MOq4z/CACOdDzRIGsf2Oenm 9aKWhcp4L/rigiGEo+fIrbPPhAdbW4jURSZDmhQL0C02eeRA7TDb4DnEGRrmRyU6YeY1 +e5xrz8Rn0WYT2zB7+c6cQxTg7lRmbWayFE1KWh2D+/SoiWfz6c+P+eQGw21JBjQlrft MxNJYrvH0k5qfFmF9eWPf/JURIy13tMpGqSulMHy86bjkWNCMCuVOW/iprRx9lM9O44d SmVHsReozZf45KirWQHwmW09NdM22KkfS/lAVRhCKNvoZCw/5x6NE4Jm47ltk+jf4uD4 MKRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=HvEz9CKHzxtzvNoHA5Fmrb6C0KKdJr3425fVCr2E2Q0=; b=Qs7JPuQ7XRAzJ5F8v2bPlO578vsqTPb2+8D/etywrYwviR9vK1x8clFalvlhYQVoGc p7LlvNYsAEo3ARpLwlxmeRyv08wso1UQwLN7DZRddudqA7ViB/Yskhz6LY4Vt4VoghJ3 o0HpC9MH+VQbwPCwgJ3mzPu+KrA71nKGUeq2xyxZqBegfssFfGQal/OwUq3lhyowAyCM VUAoKP1OW6/PGtZ1rXxppx21yTU7yG8ba0wb1ZQsqX37L2dCLjabzB0kIlhMulOW+SiH a5d74EpMCo76iSfpEKi6Lph5EkLuBut0cp7nHMM7xQEqY/JL3XkS2pNcxOfQPIVVVvFl doCA== X-Gm-Message-State: ALyK8tJgWPtMabVuvMVdPtmKQoGxJKefsW/KbjwNVKMvs5SAImEYG1hE9eJHadN6f8xU1Q== X-Received: by 10.202.190.69 with SMTP id o66mr2623310oif.7.1466879897778; Sat, 25 Jun 2016 11:38:17 -0700 (PDT) Received: from linux.site (cpe-24-31-249-175.kc.res.rr.com. [24.31.249.175]) by smtp.gmail.com with ESMTPSA id w6sm5736850ota.10.2016.06.25.11.38.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 25 Jun 2016 11:38:17 -0700 (PDT) From: Larry Finger To: kvalo@codeaurora.org Cc: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org, Larry Finger , Pavel Andrianov Subject: [PATCH 5/6] rtlwifi: rtl8723ae: Fix potential race condition Date: Sat, 25 Jun 2016 13:37:46 -0500 Message-Id: <1466879867-2499-6-git-send-email-Larry.Finger@lwfinger.net> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1466879867-2499-1-git-send-email-Larry.Finger@lwfinger.net> References: <1466879867-2499-1-git-send-email-Larry.Finger@lwfinger.net> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Larry Finger Cc: Pavel Andrianov --- drivers/net/wireless/realtek/rtlwifi/rtl8723ae/dm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/dm.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/dm.c index 4c1c96c..3900e10 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/dm.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/dm.c @@ -816,6 +816,7 @@ void rtl8723e_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)) { @@ -829,6 +830,7 @@ void rtl8723e_dm_watchdog(struct ieee80211_hw *hw) rtl8723e_dm_bt_coexist(hw); rtl8723e_dm_check_edca_turbo(hw); } + spin_unlock(&rtlpriv->locks.rf_ps_lock); if (rtlpriv->btcoexist.init_set) rtl_write_byte(rtlpriv, 0x76e, 0xc); }