All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhao Li <enderaoelyther@gmail.com>
To: Jeff Johnson <jjohnson@kernel.org>
Cc: Kalle Valo <kvalo@kernel.org>, Wen Gong <quic_wgong@quicinc.com>,
	Baochen Qiang <baochen.qiang@oss.qualcomm.com>,
	Anilkumar Kolli <quic_akolli@quicinc.com>,
	linux-wireless@vger.kernel.org, ath11k@lists.infradead.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Zhao Li <enderaoelyther@gmail.com>
Subject: [PATCH ath-current 1/3] wifi: ath11k: don't walk an unallocated regulatory info store
Date: Wed, 18 Nov 2026 23:29:40 +0800	[thread overview]
Message-ID: <20261118152942.62838-2-enderaoelyther@gmail.com> (raw)
In-Reply-To: <20261118152942.62838-1-enderaoelyther@gmail.com>

ath11k_reg_free() resets the regulatory information of every radio in
ab->reg_info_store before it frees the store, without checking that the
store exists. SERVICE_READY_EXT counts the radios before it allocates
the store, and since commit 64828f091c7d ("wifi: ath11k: fix
reg_info_store leak in ath11k_service_ready_ext_event()") its error path
can also free the store after a firmware restart, so ab->num_radios can
be set while the store is NULL. A later ath11k_reg_free() then resets
the radios through the NULL store and faults on the second radio.

Reset the radios only when the store exists.

AI assistance was used.

Fixes: 7004bdceef60 ("wifi: ath11k: store cur_regulatory_info for each radio")
Cc: stable@vger.kernel.org
Signed-off-by: Zhao Li <enderaoelyther@gmail.com>
---
Found by code review. Tested in QEMU with KASAN, using a test module
and a test-only allocation failure in the SERVICE_READY_EXT handler that
leave a two-radio synthetic device without a store, and then calls
ath11k_reg_free(): without this change the call faults in
ath11k_reg_free(); with the series applied it completes.

No new W=1, sparse or smatch warnings.

 drivers/net/wireless/ath/ath11k/reg.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/reg.c b/drivers/net/wireless/ath/ath11k/reg.c
index 1030e119fd90..13e2ac96a12c 100644
--- a/drivers/net/wireless/ath/ath11k/reg.c
+++ b/drivers/net/wireless/ath/ath11k/reg.c
@@ -1049,8 +1049,10 @@ void ath11k_reg_free(struct ath11k_base *ab)
 {
 	int i;
 
-	for (i = 0; i < ab->num_radios; i++)
-		ath11k_reg_reset_info(&ab->reg_info_store[i]);
+	if (ab->reg_info_store) {
+		for (i = 0; i < ab->num_radios; i++)
+			ath11k_reg_reset_info(&ab->reg_info_store[i]);
+	}
 
 	kfree(ab->reg_info_store);
 	ab->reg_info_store = NULL;
-- 
2.56.1


  reply	other threads:[~2026-11-18 15:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 15:29 [PATCH ath-current 0/3] wifi: ath11k: give the regulatory state the lifetime of the device Zhao Li
2026-11-18 15:29 ` Zhao Li [this message]
2026-11-18 15:29 ` [PATCH ath-current 2/3] wifi: ath11k: free the regulatory state when the device is freed Zhao Li
2026-11-18 15:29 ` [PATCH ath-current 3/3] wifi: ath11k: keep the regulatory info store on a SERVICE_READY_EXT error Zhao Li

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=20261118152942.62838-2-enderaoelyther@gmail.com \
    --to=enderaoelyther@gmail.com \
    --cc=ath11k@lists.infradead.org \
    --cc=baochen.qiang@oss.qualcomm.com \
    --cc=jjohnson@kernel.org \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=quic_akolli@quicinc.com \
    --cc=quic_wgong@quicinc.com \
    --cc=stable@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.