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: 910052 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gKvu04t2"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40gBsk02Cwz9s0W for ; Tue, 8 May 2018 18:07:05 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754399AbeEHIGt (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: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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;