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 --- 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