From patchwork Tue May 8 08:06:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia-Ju Bai X-Patchwork-Id: 10385511 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 0DCE460353 for ; Tue, 8 May 2018 08:07:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02C6620121 for ; Tue, 8 May 2018 08:07:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB57028AA6; Tue, 8 May 2018 08:07:06 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable 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 95FDE20121 for ; Tue, 8 May 2018 08:07:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754402AbeEHIGt (ORCPT ); Tue, 8 May 2018 04:06:49 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:35182 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754296AbeEHIGo (ORCPT ); Tue, 8 May 2018 04:06:44 -0400 Received: by mail-pg0-f68.google.com with SMTP id j11-v6so20833383pgf.2; Tue, 08 May 2018 01:06:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=79rNItQrjZHJ5auhVICd4WULjkHISOO/T+xJGwJhL+g=; b=gKvu04t2FuFpDUIxLk9E4kl0k36+zd098jB2TJsekN/0W0fJYrq6NhZFQoOK8RD3Fy YI4yGAYrg9+itxxJuQj9uoPy8L9D14uElirU7DK02gWYVQ1eHALVs5O8D9V4Yl/XZK5/ WiA91T8mKBC7mOVapCIkN7VyXVJrNUPef7UkxN5RcATIGZO41qaU6gB5We5cNqZpSdGY vGp7ytsN6MQtl48w+eqf70szW5tGWNJg+v4ZcC1XZWU5rBWwGmGfgjTPXtsHmpDkM2vy aoTOtoZCR+FL2dQ61LpjD8HR2TBtsqTZ5rSUF+1OKqOIOqscdBMAjedKFmDLaK7XTqxb smAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=79rNItQrjZHJ5auhVICd4WULjkHISOO/T+xJGwJhL+g=; b=poDpBmZUr5t7GCeaGcQvugzeKrtIvW3tOmB6sRUTPMa38NiDaCDfsCuHI66nIV9iNr SGGtMoF8PpiGlgKlvCaj+hz5YSqvXjsTNJO4jhQtZlTAd2YJH+Yk0TgsmryaX/YJPXF8 D0w70eihRNa4Qh7n9c86g7K97JFl0s57+vNwUxzwRvmAlu0B2cPibh41XqjDQcUaPrW7 D/XLEwriDbi8+vpUyy+er5kIJgxlAhKtwU4DN0sALhidMSQ7y4VJp25rTOcdKK0+X9ZJ Uck3aVTgx8iC4VbrnFYzDHUpc+zfhczVBAEJrYi/xay8E4n9ANHoUvRS52Fee2YLgNzK Hn2A== X-Gm-Message-State: ALQs6tAR+dGrIQe1kefMvmmu09ORxfoj/V3vk+nlmfUHerD7eFGi2KR+ aa+7SMnvfrbD2kdJCkrKiJwO8A== X-Google-Smtp-Source: AB8JxZqrZ556BaIh7WxX+DOtCNZNzgypn44276yjKhs9GeaA//cRZDhIKgaltsZCa1c3SaBV40BhEA== X-Received: by 10.98.198.21 with SMTP id m21mr34570549pfg.232.1525766804222; Tue, 08 May 2018 01:06:44 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:9049:25cd:b90:73a0]) by smtp.gmail.com with ESMTPSA id n83sm53965284pfi.183.2018.05.08.01.06.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 May 2018 01:06:43 -0700 (PDT) From: Jia-Ju Bai To: ath9k-devel@qca.qualcomm.com, kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] net: wireless: ath: ath9k: Fix a possible data race in ath_chanctx_set_next Date: Tue, 8 May 2018 16:06:36 +0800 Message-Id: <20180508080636.13827-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 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 The write operation to "sc->next_chan" is protected by the lock on line 1287, but the read operation to this data on line 1262 is not protected by the lock. Thus, there may exist a data race for "sc->next_chan". To fix this data race, the read operation to "sc->next_chan" should be also protected by the lock. Signed-off-by: Jia-Ju Bai --- drivers/net/wireless/ath/ath9k/channel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath9k/channel.c b/drivers/net/wireless/ath/ath9k/channel.c index 1b05b5d7a038..ed3cd5523481 100644 --- a/drivers/net/wireless/ath/ath9k/channel.c +++ b/drivers/net/wireless/ath/ath9k/channel.c @@ -1257,12 +1257,12 @@ void ath_chanctx_set_next(struct ath_softc *sc, bool force) "Stopping current chanctx: %d\n", sc->cur_chan->chandef.center_freq1); sc->cur_chan->stopped = true; - spin_unlock_bh(&sc->chan_lock); if (sc->next_chan == &sc->offchannel.chan) { getrawmonotonic(&ts); measure_time = true; } + spin_unlock_bh(&sc->chan_lock); ath9k_chanctx_stop_queues(sc, sc->cur_chan); queues_stopped = true;