[PATCH ath-next v5 11/12] wifi: ath10k: move sdio irqs_disabled completion off the stack
From: Kang Yang
Date: Wed Dec 02 2026 - 01:10:30 EST
ath10k_sdio_irq_disable() puts irqs_disabled_comp on its own stack and
hands its address to ath10k_sdio_prep_async_req(), which stores it in
bus_req->comp. If wait_for_completion_timeout() expires while the
request is still queued, ath10k_sdio_irq_disable() returns and that
stack frame dies. A later complete(req->comp) from
ath10k_sdio_write_async_work() then writes through a dangling pointer.
Move irqs_disabled_comp into struct ath10k_sdio so it outlives any
queued request, init it once at probe, and reinit it on every
disable.
Tested-on: QCA6174 hw3.2 PCI WLAN.RM.4.4.1-00288-QCARMSWPZ-1
Tested-on: QCA6174 hw3.2 SDIO WLAN.RMH.4.4.1-00189
Fixes: d96db25d2025 ("ath10k: add initial SDIO support")
Signed-off-by: Kang Yang <kang.yang@xxxxxxxxxxxxxxxx>
---
drivers/net/wireless/ath/ath10k/sdio.c | 12 +++++++-----
drivers/net/wireless/ath/ath10k/sdio.h | 1 +
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/ath/ath10k/sdio.c b/drivers/net/wireless/ath/ath10k/sdio.c
index bb2bb885b9da..2503af73ad67 100644
--- a/drivers/net/wireless/ath/ath10k/sdio.c
+++ b/drivers/net/wireless/ath/ath10k/sdio.c
@@ -1925,7 +1925,6 @@ static void ath10k_sdio_irq_disable(struct ath10k *ar)
struct ath10k_sdio_irq_data *irq_data = &ar_sdio->irq_data;
struct ath10k_sdio_irq_enable_regs *regs = irq_data->irq_en_reg;
struct sk_buff *skb;
- struct completion irqs_disabled_comp;
int ret;
skb = dev_alloc_skb(sizeof(*regs));
@@ -1940,18 +1939,20 @@ static void ath10k_sdio_irq_disable(struct ath10k *ar)
mutex_unlock(&irq_data->mtx);
- init_completion(&irqs_disabled_comp);
+ reinit_completion(&ar_sdio->irqs_disabled_comp);
ret = ath10k_sdio_prep_async_req(ar, MBOX_INT_STATUS_ENABLE_ADDRESS,
- skb, &irqs_disabled_comp, false, 0);
+ skb, &ar_sdio->irqs_disabled_comp,
+ false, 0);
if (ret)
goto out;
queue_work(ar_sdio->workqueue, &ar_sdio->wr_async_work);
- /* Wait for the completion of the IRQ disable request.
+ /*
+ * Wait for the completion of the IRQ disable request.
* If there is a timeout we will try to disable irq's anyway.
*/
- ret = wait_for_completion_timeout(&irqs_disabled_comp,
+ ret = wait_for_completion_timeout(&ar_sdio->irqs_disabled_comp,
SDIO_IRQ_DISABLE_TIMEOUT_HZ);
if (!ret)
ath10k_warn(ar, "sdio irq disable request timed out\n");
@@ -2580,6 +2581,7 @@ static int ath10k_sdio_probe(struct sdio_func *func,
spin_lock_init(&ar_sdio->lock);
spin_lock_init(&ar_sdio->wr_async_lock);
mutex_init(&ar_sdio->irq_data.mtx);
+ init_completion(&ar_sdio->irqs_disabled_comp);
INIT_LIST_HEAD(&ar_sdio->bus_req_freeq);
INIT_LIST_HEAD(&ar_sdio->wr_asyncq);
diff --git a/drivers/net/wireless/ath/ath10k/sdio.h b/drivers/net/wireless/ath/ath10k/sdio.h
index b6ac927628b1..e15d941d4db9 100644
--- a/drivers/net/wireless/ath/ath10k/sdio.h
+++ b/drivers/net/wireless/ath/ath10k/sdio.h
@@ -226,6 +226,7 @@ struct ath10k_sdio {
struct work_struct async_work_rx;
struct timer_list sleep_timer;
enum sdio_mbox_state mbox_state;
+ struct completion irqs_disabled_comp;
};
static inline struct ath10k_sdio *ath10k_sdio_priv(struct ath10k *ar)
--
2.34.1