From patchwork Sat Jun 25 18:37:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Finger X-Patchwork-Id: 9198643 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 1FB1860754 for ; Sat, 25 Jun 2016 18:38:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 140B828522 for ; Sat, 25 Jun 2016 18:38:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0073E28526; 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 A2A0928522 for ; Sat, 25 Jun 2016 18:38:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751782AbcFYSiY (ORCPT ); Sat, 25 Jun 2016 14:38:24 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:35307 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751660AbcFYSiQ (ORCPT ); Sat, 25 Jun 2016 14:38:16 -0400 Received: by mail-oi0-f66.google.com with SMTP id d132so23953065oig.2 for ; Sat, 25 Jun 2016 11:38:16 -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=0KhuX/7EUXay6CWasbhVRoKFF+xScOZInvcqc67qAHA=; b=pHlFToVa+F+1tWJ0NKDxgH+GAfAVac8gZ5asORg7yGH4i7FhtBeLH2800zY1V1buDR tyiOBctCrfGtWoaYW/dVv21V8dNBQLRsgQRUH0qPEB1Jxz2+OKcU6Hn6uqcyVGjd0bkY OdpVZNwg7dhTe3iqYVrgH361wDVKyYaIJjuv1pOATxj+Gmo84lP2fs+1PqD042Da8c8F 1GwXGFPoJpQiOhQsTJDy6kUHMKaLMP9vJiNjWqrHZbcLx0DK205LMOe/GRkBmEB/gUrC nJipXvRQt8tYQG8LLCh6Pf0AqszptVrmqG5SutgWwhkY+98hK9yBKV6E9mEK3Pd0DyRG xs9g== 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=0KhuX/7EUXay6CWasbhVRoKFF+xScOZInvcqc67qAHA=; b=DBW8BR86FiJPdfSmWbkaEWjuvM/2qNArtSw6qflVYSYGFmPOJiGdi+OmbxTNoIP7el NNMWdlB6+ZDl+UFNPgSRvaQNKza98dDZsCIbYlBNnzIEDOiYOh7VUv01AtZ4MAVPIWXQ 2ziuqdd9Fd7M7XGZd/p8Uq1IWcURxo8s5mWVmB1EumobV4dreyKnZuXhG+qSVF1yWnHK hcWl/fdBcq/f65ArRxwQaNjlJU7CeLos89sKyTMJChQWUA4qgjBCFS9KlMMRKsPa6Jal sNBHI7u4bKuGo6ALvxwcFMAEjSnAk4ZAIId5udXqjRQO92TO7nVSlUWbUuJLZd0pwRcU rTYQ== X-Gm-Message-State: ALyK8tIMdktMlYWkZqQBVWs8Wk4jrQctWQu0GWSEetH6uMJupw2oFlMU6GBlBwaC2vWVpw== X-Received: by 10.202.74.136 with SMTP id x130mr6902262oia.44.1466879896193; Sat, 25 Jun 2016 11:38:16 -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.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 25 Jun 2016 11:38:15 -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 3/6] rtlwifi: rtl8192ee: Fix potential race condition Date: Sat, 25 Jun 2016 13:37:44 -0500 Message-Id: <1466879867-2499-4-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 rtl92ee_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/rtl8192ee/dm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/dm.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/dm.c index 459f3d0..46efba0 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/dm.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/dm.c @@ -1219,6 +1219,7 @@ void rtl92ee_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)) { @@ -1233,4 +1234,5 @@ void rtl92ee_dm_watchdog(struct ieee80211_hw *hw) rtl92ee_dm_dynamic_atc_switch(hw); rtl92ee_dm_dynamic_primary_cca_ckeck(hw); } + spin_unlock(&rtlpriv->locks.rf_ps_lock); }