From: Kalle Valo <kvalo@codeaurora.org>
To: Peter Oh <peter.oh@eero.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
kernel-janitors@vger.kernel.org,
Carl Huang <cjhuang@codeaurora.org>,
linux-wireless@vger.kernel.org, ath11k@lists.infradead.org
Subject: Re: [PATCH] ath11k: fix a locking bug in ath11k_mac_op_start()
Date: Tue, 02 Feb 2021 06:32:44 +0200 [thread overview]
Message-ID: <875z3b84yb.fsf@codeaurora.org> (raw)
In-Reply-To: <896a68dd-02ec-4fe3-3fbf-ec1bd2decefe@eero.com> (Peter Oh's message of "Mon, 1 Feb 2021 13:47:27 -0800")
Peter Oh <peter.oh@eero.com> 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 <dan.carpenter@oracle.com>
>> ---
>> 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.
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.
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
prev parent reply other threads:[~2021-02-02 4:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-01 12:24 [PATCH] ath11k: fix a locking bug in ath11k_mac_op_start() Dan Carpenter
2021-02-01 21:47 ` Peter Oh
2021-02-02 4:32 ` Kalle Valo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875z3b84yb.fsf@codeaurora.org \
--to=kvalo@codeaurora.org \
--cc=ath11k@lists.infradead.org \
--cc=cjhuang@codeaurora.org \
--cc=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=peter.oh@eero.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).