* [PATCH ath-current] wifi: ath12k: fail the start when a service ready event fails
@ 2026-11-19 7:56 Zhao Li
0 siblings, 0 replies; only message in thread
From: Zhao Li @ 2026-11-19 7:56 UTC (permalink / raw)
To: Jeff Johnson
Cc: Pradeep Kumar Chitrapu, Bhagavathi Perumal S,
Karthikeyan Periyasamy, Baochen Qiang, linux-wireless, ath12k,
linux-kernel, stable, Zhao Li
ath12k_core_start() waits for the service ready handshake, in which the
firmware sends SERVICE_READY, SERVICE_READY_EXT and, if it supports it,
SERVICE_READY_EXT2. Only the last of these events completes the wait,
whenever its own TLVs parse, so the start goes on after an earlier event
failed (for example, on -ENOMEM or a malformed TLV), with capabilities
that were only partly extracted. An event that arrives again, even after
the start, is handled again and rewrites the capabilities under a
running driver.
Track the next service ready event that this start accepts. Each handler
takes only its own event in turn, closes the handshake before parsing
and opens it for the next event only on success. A failed event then
makes ath12k_wmi_wait_for_service_ready() time out, and any event out of
turn, including one after the handshake completed, is ignored.
Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices")
Cc: stable@vger.kernel.org # needs adjustments for <= 6.12
Signed-off-by: Zhao Li <enderaoelyther@gmail.com>
---
Found by code review. Tested in a QEMU guest with KASAN and a test hook
that feeds service ready events to a synthetic device: without this
change the start completed after a failed SERVICE_READY or
SERVICE_READY_EXT, and duplicate or out-of-turn events were parsed again
after the handshake; with it the failed start timed out and those events
were dropped before parsing.
No new W=1, sparse or smatch warnings.
AI assistance was used.
drivers/net/wireless/ath/ath12k/wmi.c | 22 +++++++++++++++++++++-
drivers/net/wireless/ath/ath12k/wmi.h | 9 +++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c
index 75b259990c79..89e4dec07534 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.c
+++ b/drivers/net/wireless/ath/ath12k/wmi.c
@@ -732,6 +732,11 @@ static int ath12k_service_ready_event(struct ath12k_base *ab, struct sk_buff *sk
struct ath12k_wmi_svc_ready_parse svc_ready = { };
int ret;
+ if (ab->wmi_ab.svc_rdy_next != ATH12K_WMI_SVC_RDY)
+ return -EPROTO;
+
+ ab->wmi_ab.svc_rdy_next = ATH12K_WMI_SVC_RDY_NONE;
+
ret = ath12k_wmi_tlv_iter(ab, skb->data, skb->len,
ath12k_wmi_svc_rdy_parse,
&svc_ready);
@@ -740,6 +745,8 @@ static int ath12k_service_ready_event(struct ath12k_base *ab, struct sk_buff *sk
return ret;
}
+ ab->wmi_ab.svc_rdy_next = ATH12K_WMI_SVC_RDY_EXT;
+
return 0;
}
@@ -5148,6 +5155,11 @@ static int ath12k_service_ready_ext_event(struct ath12k_base *ab,
struct ath12k_wmi_svc_rdy_ext_parse svc_rdy_ext = { };
int ret;
+ if (ab->wmi_ab.svc_rdy_next != ATH12K_WMI_SVC_RDY_EXT)
+ return -EPROTO;
+
+ ab->wmi_ab.svc_rdy_next = ATH12K_WMI_SVC_RDY_NONE;
+
ret = ath12k_wmi_tlv_iter(ab, skb->data, skb->len,
ath12k_wmi_svc_rdy_ext_parse,
&svc_rdy_ext);
@@ -5156,7 +5168,9 @@ static int ath12k_service_ready_ext_event(struct ath12k_base *ab,
goto err;
}
- if (!test_bit(WMI_TLV_SERVICE_EXT2_MSG, ab->wmi_ab.svc_map))
+ if (test_bit(WMI_TLV_SERVICE_EXT2_MSG, ab->wmi_ab.svc_map))
+ ab->wmi_ab.svc_rdy_next = ATH12K_WMI_SVC_RDY_EXT2;
+ else
complete(&ab->wmi_ab.service_ready);
kfree(svc_rdy_ext.mac_phy_caps);
@@ -5871,6 +5885,11 @@ static int ath12k_service_ready_ext2_event(struct ath12k_base *ab,
struct ath12k_wmi_svc_rdy_ext2_parse svc_rdy_ext2 = { };
int ret;
+ if (ab->wmi_ab.svc_rdy_next != ATH12K_WMI_SVC_RDY_EXT2)
+ return -EPROTO;
+
+ ab->wmi_ab.svc_rdy_next = ATH12K_WMI_SVC_RDY_NONE;
+
ret = ath12k_wmi_tlv_iter(ab, skb->data, skb->len,
ath12k_wmi_svc_rdy_ext2_parse,
&svc_rdy_ext2);
@@ -10788,6 +10807,7 @@ int ath12k_wmi_attach(struct ath12k_base *ab)
/* TODO: Init remaining wmi soc resources required */
init_completion(&ab->wmi_ab.service_ready);
init_completion(&ab->wmi_ab.unified_ready);
+ ab->wmi_ab.svc_rdy_next = ATH12K_WMI_SVC_RDY;
return 0;
}
diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h
index b508aa759bd8..59bf691352bd 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.h
+++ b/drivers/net/wireless/ath/ath12k/wmi.h
@@ -5397,6 +5397,13 @@ struct ath12k_hw_mode_info {
[MAX_RADIOS];
};
+enum ath12k_wmi_svc_rdy {
+ ATH12K_WMI_SVC_RDY_NONE,
+ ATH12K_WMI_SVC_RDY,
+ ATH12K_WMI_SVC_RDY_EXT,
+ ATH12K_WMI_SVC_RDY_EXT2,
+};
+
struct ath12k_wmi_base {
struct ath12k_base *ab;
struct ath12k_wmi_pdev wmi[MAX_RADIOS];
@@ -5405,6 +5412,8 @@ struct ath12k_wmi_base {
struct completion service_ready;
struct completion unified_ready;
+ /* Next service ready event this start accepts */
+ enum ath12k_wmi_svc_rdy svc_rdy_next;
DECLARE_BITMAP(svc_map, WMI_MAX_EXT2_SERVICE);
wait_queue_head_t tx_credits_wq;
u32 num_mem_chunks;
base-commit: b1ed5a45b994a6473ca1cf34f35a1bf87f1d8e2a
--
2.56.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-19 7:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 7:56 [PATCH ath-current] wifi: ath12k: fail the start when a service ready event fails Zhao Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox