From patchwork Sat Jun 25 18:37:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Finger X-Patchwork-Id: 9198641 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 50DE5608A7 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 4500428522 for ; Sat, 25 Jun 2016 18:38:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36B1928525; 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 D073D28525 for ; Sat, 25 Jun 2016 18:38:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751804AbcFYSiY (ORCPT ); Sat, 25 Jun 2016 14:38:24 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:33506 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751722AbcFYSiT (ORCPT ); Sat, 25 Jun 2016 14:38:19 -0400 Received: by mail-oi0-f68.google.com with SMTP id w141so24017518oia.0 for ; Sat, 25 Jun 2016 11:38:19 -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=9lEwK9KH7pRBEhkOiMUF2Px4TP3i8tNstu3KoaPv6nI=; b=STZ9oH0X0od8E3cPVmlLCReLd6QjVcIvaBFMxvF2I7Dz21p+7qfmjJQ3y4M0jkQ8XI AJUrLmyF6SfqZn9mt+u+gb1HNxpNUJ6bamG+f0lCu/NQCclBWe3KrUql6GxS8udqtP63 VOfi3UXtK9pzqdDXqe3U/2Mnl3yQc3fuomrIMQJbxbu2SRPQKkzfVnwfpnYbCr89Iwwc RnxUlPDSwDu+nHQVjZPVzTb1iWQrYRfiJHNXgGs/rAVrXTMDZRZXSjbqq+K5O9OS5aft LevyCBRVafP3t3ibd5fAaYafjfaWZGgsl19zX3ptIzAEhbU0o1ZimnLPAf9LBoXOiI/o nQrg== 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=9lEwK9KH7pRBEhkOiMUF2Px4TP3i8tNstu3KoaPv6nI=; b=HL4eU8V50gdqFT1FWvMkIx6X+zTsQ0qPyxGfwfUEfZJQYoCOdg4rtQSCm/IOeud0xt HCz4fTfcSbdwpLMzRnUs4Wrv6y8QLiSHGHuynr9oqIqFx5JeZPRZzeFTgZ1dOzUZL28V 9HPGXzzA+vHuZZInPKs3hvLWh4KPfgIvCqKTYU331oyXhcqiF5JtHlA3BEw2WJZv9XyD hJoLWKCf5QLjRakNZIisPymfxuz97f2n9NGBMwPsZWbfNK1SqvyVTM+ShjXLbeUloO0C W+1O97sgTfL3EIcVSt4dv5JURBUKDWNZC0s9SVfIfKalAkXQZgyFTxte5FCUvqQhTh5j q8gg== X-Gm-Message-State: ALyK8tJLziXo3DYSApZPL6JTz/pkCMxMF79RnVUZaZj+wiIGHY2B/5rKU+wgjI1SGPaOrA== X-Received: by 10.202.56.139 with SMTP id f133mr5776963oia.82.1466879898532; Sat, 25 Jun 2016 11:38:18 -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:18 -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 6/6] rtlwifi: rtl8821ae: Fix potential race condition Date: Sat, 25 Jun 2016 13:37:47 -0500 Message-Id: <1466879867-2499-7-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 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 --- drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c index 17a6817..35c6f8a 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");