Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4146394pxb; Mon, 1 Feb 2021 13:48:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUA9MppFWb4FgjMgwFb9gNxb76stI6z2ydl03teIgZr/tRKHIqp7wtYLQ5oqgSYxCnJoHe X-Received: by 2002:a17:907:f81:: with SMTP id kb1mr13431335ejc.466.1612216132660; Mon, 01 Feb 2021 13:48:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612216132; cv=none; d=google.com; s=arc-20160816; b=C2UBqf7jz4fu2BmG1AWf4QaTBWasm92pfjr+um+MLBhSV6lt3UWQBT/T5GzHZ9EcU+ TI6rwuZpVrNp/rK4OHmMgx9aQmeLSF2RcbtW3zG2mEBLOyP1bdBt7nPekGdMYTxYpKs/ rr6IJUriGpJIc9M1kuBTPuGUNSdMZyuIWbGLyBHzRc1rag9BPF8XyNrEvG72W+kVvvjJ XubMHLdv8MxCXF7zsKCZ2M50/KZ/PI+2JWXNjFghXsHRnVuFFdjSKewKRuILx5QNF3a7 Nxzf1XOboqyYtmG5GzSIr6YQW7GU/nwdwL00/sb9/IqN1DpyczED6Jhev70n8WZ757Ou Q0Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=3jrybrZXt/b8n85ODtKeUfuhoYR0zahuJQZ5wiSQlzo=; b=q+fJHIWpUi4I7VRljGm8vRLl/k969O8yJe2jyMIKykWSpfeTfP+AVGPOSS+psRj+aw HjHNknSQRkOlh0wDpu+h+bPxcuip2YXIzaXAHk7/c/qjqyh5JlesXf2nkTTcg4genqyt DSFM96Zdh5+b8OA8M4iW3CZUtrfKJdguwhAYze8EQxjzK6dS88jXMqujPwm6L7hUR+za 4bT8MG3/3AhGbRy8BCgOh6wNUDF4M19Xdc8hF1/M9ZpyZ31DLeiIT7eUSB2s8+o7vNfg HS1mhdVvvGvMX0CD51E/U0BCidTgzyh/NIuKFiPUpehRfpNNV/hAToPGH0SNea7078PO Oxeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@eero.com header.s=google header.b=IJxDv9cn; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=eero.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q1si11941889edi.331.2021.02.01.13.48.26; Mon, 01 Feb 2021 13:48:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@eero.com header.s=google header.b=IJxDv9cn; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=eero.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229612AbhBAVsX (ORCPT + 99 others); Mon, 1 Feb 2021 16:48:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbhBAVsR (ORCPT ); Mon, 1 Feb 2021 16:48:17 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20CC0C061756 for ; Mon, 1 Feb 2021 13:47:31 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id o16so13020096pgg.5 for ; Mon, 01 Feb 2021 13:47:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eero.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=3jrybrZXt/b8n85ODtKeUfuhoYR0zahuJQZ5wiSQlzo=; b=IJxDv9cnOzJcP7D1qRq5hv6GEqCDerCAexj1WliDB9nKLO59T8Ad56+k8H9wlKGayV FV+4OuDVN4hgvAhH2HiJUFapyQ/RyuKUqPf9dCJIOrpAxIT15LTHl3HDSq2F1HwAaLD/ PS4c966O/2fDKeeCNd4rntZ0HTOBPzkBAaoqk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=3jrybrZXt/b8n85ODtKeUfuhoYR0zahuJQZ5wiSQlzo=; b=p5xvXg27C+M+uFxSj2NvI3CHN6wa5wUFB13aCyiNiNvLOibgY1Fz+bcBja01Z301Bi ZGjUy8qEacaLbPzNEM/SG6NRIXD05Fh4m1GvwJXlUP0ogN67PJvkIY+io0qKGSUYCjnD 722plRI2H5ZiqScA9cfiRCCjSxTAF4uSVAwZW3vG3ZduHg8WOC+XezE5ZFcz/ZnQjWn3 IckxiBJaNg+Mei9rc0HMnzJw7a8ewbTzorbMofoYAsjbHK2noLDGuHf/4SS1Dpcfxb+3 HU/qR083GpW/eBWRAKyOVVDp2fUT0THGKulB2YTMcXCgQLf/yLD3l7ekA1sTcT6BDCcK sKDA== X-Gm-Message-State: AOAM533SyPbpzU6KSQW8gW8z1ZDidb4l8PMgFRSg0Y4mvtwI03JwtMwM qkCgx7WU/owi4fwKD3x57aRERA== X-Received: by 2002:a63:9811:: with SMTP id q17mr19079307pgd.238.1612216050662; Mon, 01 Feb 2021 13:47:30 -0800 (PST) Received: from [192.168.4.200] (107-196-182-50.lightspeed.sntcca.sbcglobal.net. [107.196.182.50]) by smtp.gmail.com with ESMTPSA id 6sm18558803pfd.212.2021.02.01.13.47.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Feb 2021 13:47:30 -0800 (PST) Subject: Re: [PATCH] ath11k: fix a locking bug in ath11k_mac_op_start() To: Dan Carpenter , Kalle Valo Cc: Carl Huang , ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, kernel-janitors@vger.kernel.org References: From: Peter Oh Message-ID: <896a68dd-02ec-4fe3-3fbf-ec1bd2decefe@eero.com> Date: Mon, 1 Feb 2021 13:47:27 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On 2/1/21 4:24 AM, Dan Carpenter wrote: > This error path leads to a Smatch warning: > > drivers/net/wireless/ath/ath11k/mac.c:4269 ath11k_mac_op_start() > error: double unlocked '&ar->conf_mutex' (orig line 4251) > > We're not holding the lock when we do the "goto err;" so it leads to a > double unlock. We should hold the lock because the error path sets > "ar->state" so the right fix is to take the lock before doing the goto. > > Fixes: c83c500b55b6 ("ath11k: enable idle power save mode") > Signed-off-by: Dan Carpenter > --- > drivers/net/wireless/ath/ath11k/mac.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c > index c1608f64ea95..12e981e9e3d7 100644 > --- a/drivers/net/wireless/ath/ath11k/mac.c > +++ b/drivers/net/wireless/ath/ath11k/mac.c > @@ -4259,6 +4259,7 @@ static int ath11k_mac_op_start(struct ieee80211_hw *hw) > 1, pdev->pdev_id); > if (ret) { > ath11k_err(ab, "failed to enable idle ps: %d\n", ret); > + mutex_lock(&ar->conf_mutex); > goto err; > } > } It seems moving idle_ps condition in between ath11k_wmi_pdev_lro_cfg() and mutex_unlock()  is a better way in this case. Thanks, Peter