From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BB3DC433DB for ; Tue, 2 Feb 2021 04:33:17 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E7EA664E9C for ; Tue, 2 Feb 2021 04:33:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7EA664E9C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=ath11k-bounces+ath11k=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:In-Reply-To:Date:References: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=b1AA3n0lGS71qHRhqEmPthT6FuJmG1xvjRzUynR5j1A=; b=1AZKeJ88+8llYoMTz1Lv8ZUad Mbor1akowRQqJM8mdSGqR33hKKXJmjmmsZbaP4Cg2qqSGejc3DhSiU8+ZvVlpzs+1S4Tiw7v6VgJn Id/3uTkmwoDtQCNR7Ud7H8ZrrBWU5lvoOfBxVJmIGIJas75qoBFgv0DU0XR/LerzGUYDOqhja9qal nuW1ZHhaE8Zs1f4pwfWKM+p5pmbWuzFeBv+HzQj2Sfe6COInEIWHmWOlWcnLTga/Nm7Z6WAM5Lb1J /9cNaznOnZYpbs+jZWSBUumnoPfcQWp9Ofu27blOjUW09SDoYtfuLLnhM6u0JS5w2W3MeHlpkf9tz 1rwMUHj0A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6nNI-0003dq-HJ; Tue, 02 Feb 2021 04:33:12 +0000 Received: from mail29.static.mailgun.info ([104.130.122.29]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6nNE-0003dQ-W4 for ath11k@lists.infradead.org; Tue, 02 Feb 2021 04:33:10 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1612240386; h=Content-Transfer-Encoding: Content-Type: MIME-Version: Message-ID: In-Reply-To: Date: References: Subject: Cc: To: From: Sender; bh=PtR/UtoHlz8eXcl6vbirWe2nIkoVwvfU1OnuGoOADZk=; b=vIGSfa30UcifKG0A/XoBHXjdTWC22VFlPNS5SsnpMTXotgYN7epoUKJcC1reQI9YEYBmuvOQ gbZPFI/1cQ+I6IHgCmO0u34YYtl9kOKGY72f1ztBQEj9VcADqP6HZzqK76UfJmYBtdnOh6fj ozRBsrOQmB46rHCjlNotz9ghXBU= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyJmOGQ2ZiIsICJhdGgxMWtAbGlzdHMuaW5mcmFkZWFkLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-west-2.postgun.com with SMTP id 6018d5f167765734881759cb (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 02 Feb 2021 04:32:49 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 50043C43463; Tue, 2 Feb 2021 04:32:49 +0000 (UTC) Received: from potku.adurom.net (88-114-240-156.elisa-laajakaista.fi [88.114.240.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: kvalo) by smtp.codeaurora.org (Postfix) with ESMTPSA id E307AC433CA; Tue, 2 Feb 2021 04:32:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E307AC433CA Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=kvalo@codeaurora.org From: Kalle Valo To: Peter Oh Subject: Re: [PATCH] ath11k: fix a locking bug in ath11k_mac_op_start() References: <896a68dd-02ec-4fe3-3fbf-ec1bd2decefe@eero.com> Date: Tue, 02 Feb 2021 06:32:44 +0200 In-Reply-To: <896a68dd-02ec-4fe3-3fbf-ec1bd2decefe@eero.com> (Peter Oh's message of "Mon, 1 Feb 2021 13:47:27 -0800") Message-ID: <875z3b84yb.fsf@codeaurora.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210201_233309_160288_6B14B80E X-CRM114-Status: GOOD ( 19.51 ) X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-wireless@vger.kernel.org, Carl Huang , kernel-janitors@vger.kernel.org, ath11k@lists.infradead.org, Dan Carpenter Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "ath11k" Errors-To: ath11k-bounces+ath11k=archiver.kernel.org@lists.infradead.org UGV0ZXIgT2ggPHBldGVyLm9oQGVlcm8uY29tPiB3cml0ZXM6Cgo+IE9uIDIvMS8yMSA0OjI0IEFN LCBEYW4gQ2FycGVudGVyIHdyb3RlOgo+PiBUaGlzIGVycm9yIHBhdGggbGVhZHMgdG8gYSBTbWF0 Y2ggd2FybmluZzoKPj4KPj4gICAgICBkcml2ZXJzL25ldC93aXJlbGVzcy9hdGgvYXRoMTFrL21h Yy5jOjQyNjkgYXRoMTFrX21hY19vcF9zdGFydCgpCj4+ICAgICAgZXJyb3I6IGRvdWJsZSB1bmxv Y2tlZCAnJmFyLT5jb25mX211dGV4JyAob3JpZyBsaW5lIDQyNTEpCj4+Cj4+IFdlJ3JlIG5vdCBo b2xkaW5nIHRoZSBsb2NrIHdoZW4gd2UgZG8gdGhlICJnb3RvIGVycjsiIHNvIGl0IGxlYWRzIHRv IGEKPj4gZG91YmxlIHVubG9jay4gIFdlIHNob3VsZCBob2xkIHRoZSBsb2NrIGJlY2F1c2UgdGhl IGVycm9yIHBhdGggc2V0cwo+PiAiYXItPnN0YXRlIiBzbyB0aGUgcmlnaHQgZml4IGlzIHRvIHRh a2UgdGhlIGxvY2sgYmVmb3JlIGRvaW5nIHRoZSBnb3RvLgo+Pgo+PiBGaXhlczogYzgzYzUwMGI1 NWI2ICgiYXRoMTFrOiBlbmFibGUgaWRsZSBwb3dlciBzYXZlIG1vZGUiKQo+PiBTaWduZWQtb2Zm LWJ5OiBEYW4gQ2FycGVudGVyIDxkYW4uY2FycGVudGVyQG9yYWNsZS5jb20+Cj4+IC0tLQo+PiAg IGRyaXZlcnMvbmV0L3dpcmVsZXNzL2F0aC9hdGgxMWsvbWFjLmMgfCAxICsKPj4gICAxIGZpbGUg Y2hhbmdlZCwgMSBpbnNlcnRpb24oKykK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V4LXdpcmVsZXNzL2xpc3QvCgpodHRwczovL3dpcmVsZXNzLndp a2kua2VybmVsLm9yZy9lbi9kZXZlbG9wZXJzL2RvY3VtZW50YXRpb24vc3VibWl0dGluZ3BhdGNo ZXMKCi0tIAphdGgxMWsgbWFpbGluZyBsaXN0CmF0aDExa0BsaXN0cy5pbmZyYWRlYWQub3JnCmh0 dHA6Ly9saXN0cy5pbmZyYWRlYWQub3JnL21haWxtYW4vbGlzdGluZm8vYXRoMTFrCg== From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kalle Valo Date: Tue, 02 Feb 2021 04:32:44 +0000 Subject: Re: [PATCH] ath11k: fix a locking bug in ath11k_mac_op_start() Message-Id: <875z3b84yb.fsf@codeaurora.org> List-Id: References: <896a68dd-02ec-4fe3-3fbf-ec1bd2decefe@eero.com> In-Reply-To: <896a68dd-02ec-4fe3-3fbf-ec1bd2decefe@eero.com> (Peter Oh's message of "Mon, 1 Feb 2021 13:47:27 -0800") MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: Peter Oh Cc: linux-wireless@vger.kernel.org, Carl Huang , kernel-janitors@vger.kernel.org, ath11k@lists.infradead.org, Dan Carpenter Peter Oh writes: > 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/wireles= s/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() > =C2=A0is a better way in this case. I agree. In Dan's approach I'm worried about the race when we unlock and lock again, the state can change in that case. --=20 https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatc= hes From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEE56C433DB for ; Tue, 2 Feb 2021 04:34:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A693864EDA for ; Tue, 2 Feb 2021 04:34:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231620AbhBBEd6 (ORCPT ); Mon, 1 Feb 2021 23:33:58 -0500 Received: from so15.mailgun.net ([198.61.254.15]:19033 "EHLO so15.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231477AbhBBEd5 (ORCPT ); Mon, 1 Feb 2021 23:33:57 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1612240410; h=Content-Transfer-Encoding: Content-Type: MIME-Version: Message-ID: In-Reply-To: Date: References: Subject: Cc: To: From: Sender; bh=PtR/UtoHlz8eXcl6vbirWe2nIkoVwvfU1OnuGoOADZk=; b=rms6sCjBQ+3Ua0SfJVNoav+hqfrgiwTSRWrC79wczljo8nrwMvoAOImNMz1FAKPYKFbFZUV0 zhoqxHENjUInwPh4d9BYrvtVD9rsQpCw+GlNvSfM1B8dVQdjj0HNzUvSq8Aw5dOGVnLZDdHX erdYir3HN+mLczHjgHt7kAAfgGc= X-Mailgun-Sending-Ip: 198.61.254.15 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n06.prod.us-west-2.postgun.com with SMTP id 6018d5f2ab96aecb9f8b9913 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 02 Feb 2021 04:32:50 GMT Sender: kvalo=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 5647DC433ED; Tue, 2 Feb 2021 04:32:49 +0000 (UTC) Received: from potku.adurom.net (88-114-240-156.elisa-laajakaista.fi [88.114.240.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: kvalo) by smtp.codeaurora.org (Postfix) with ESMTPSA id E307AC433CA; Tue, 2 Feb 2021 04:32:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E307AC433CA Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=kvalo@codeaurora.org From: Kalle Valo To: Peter Oh Cc: Dan Carpenter , kernel-janitors@vger.kernel.org, Carl Huang , linux-wireless@vger.kernel.org, ath11k@lists.infradead.org Subject: Re: [PATCH] ath11k: fix a locking bug in ath11k_mac_op_start() References: <896a68dd-02ec-4fe3-3fbf-ec1bd2decefe@eero.com> Date: Tue, 02 Feb 2021 06:32:44 +0200 In-Reply-To: <896a68dd-02ec-4fe3-3fbf-ec1bd2decefe@eero.com> (Peter Oh's message of "Mon, 1 Feb 2021 13:47:27 -0800") Message-ID: <875z3b84yb.fsf@codeaurora.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Peter Oh writes: > 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/wireles= s/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() > =C2=A0is a better way in this case. I agree. In Dan's approach I'm worried about the race when we unlock and lock again, the state can change in that case. --=20 https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatc= hes