From patchwork Sat Jun 25 18:37:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Finger X-Patchwork-Id: 9198635 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 66B9B608A7 for ; Sat, 25 Jun 2016 18:38:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B70328522 for ; Sat, 25 Jun 2016 18:38:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F5A928527; Sat, 25 Jun 2016 18:38:23 +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 4314A28525 for ; Sat, 25 Jun 2016 18:38:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751662AbcFYSiR (ORCPT ); Sat, 25 Jun 2016 14:38:17 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:33485 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751626AbcFYSiQ (ORCPT ); Sat, 25 Jun 2016 14:38:16 -0400 Received: by mail-oi0-f66.google.com with SMTP id w141so24017370oia.0 for ; Sat, 25 Jun 2016 11:38:15 -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=Zd6AHCmAXhCr5TcFSn30Hn3cc2lqHqXD6ue3bAl+TOE=; b=Q2U+3U+zy/ynsslBrEVkGonLUV40vUrqSue6cgV/juI5GVI0m4xsxM3Jooou2AY7g8 gyqkWfFHzxJWEtF+x4TLHskXJSX6gJFS9myGfus42G+j47nB55VMc2fYaFk4uYfr49nQ OFt/Zwlw7TNnv1jfOGYn4X2juedPRrL27hgYXK11p9Io8XaSn/jUXPzh8U/vOhNdS3/y giBMWdn/yJ/MTsGVemH/4KsFuJDNCtcOSPkUwqm0wGtw5676z0spuvwvvBC8sB6cwFc2 D0R5UR2iXC1Rr7rf8qzcQzgCO52+dehlAaXHeqNMfyTxQDo2NVShGMBHY0L7DzL/KHnn cb4g== 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=Zd6AHCmAXhCr5TcFSn30Hn3cc2lqHqXD6ue3bAl+TOE=; b=buHnEMrgiHDkXFuAieWpbC/bsU0IWOH1SrJSfND47jOJqfJq619B5ZT7im8zB3e+Sp Ib0qrFp53HLUjTbgNYzplVuHhXHQp2GpNDV4CjiZmCNkR4e/OvCVEAV6b2X+C5vAA/U4 mH4sbzDo4tRTxSGzp1FxL8/xwgTe9pmHigo/5+avx+H/O2nCKYlAhd+47ojW8QFIBr7c EFhopUZZpXF2bBw7CCLC6+83wQboZ0Z8FZKR1W1kSTtvHs12e2ZhwoWar2jskd37dkW+ /IrmMPjNmxmO2Yv/6ny7sbFTitxnVkimH2iyqBdcbsvT0pnHzfI6RYhDAmgeOvJxtyk7 X29A== X-Gm-Message-State: ALyK8tLUgXZy+Rul7WG7EUl+7qiFBLopHVCttlPPSMXgRMqUU646cEpZYDQNPlsMqrkWgw== X-Received: by 10.202.229.206 with SMTP id c197mr5654872oih.161.1466879895426; Sat, 25 Jun 2016 11:38:15 -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.14 (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 2/6] rtlwifi: rtl8188ee: Fix potential race condition Date: Sat, 25 Jun 2016 13:37:43 -0500 Message-Id: <1466879867-2499-3-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 rtl88e_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/rtl8188ee/dm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.c b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.c index db9a782..7f2650d 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.c @@ -1790,6 +1790,7 @@ void rtl88e_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)) { @@ -1802,4 +1803,5 @@ void rtl88e_dm_watchdog(struct ieee80211_hw *hw) rtl88e_dm_check_edca_turbo(hw); rtl88e_dm_antenna_diversity(hw); } + spin_unlock(&rtlpriv->locks.rf_ps_lock); }