[PATCH net v7 3/6] net: wwan: t7xx: fix skb double free when CLDMA send sees -EACCES
From: Tim JH Chen
Date: Thu Nov 19 2026 - 20:56:35 EST
t7xx_cldma_send_skb() tolerates -EACCES from
pm_runtime_resume_and_get() and goes on to queue the skb on the GPD
ring, but it keeps that -EACCES in ret across a successful send and
returns it. The callers treat a non-zero return as "not sent" and free
the skb (t7xx_port_fastboot_write(), t7xx_port_wwan_write()), while
t7xx_cldma_gpd_tx_collect() frees it again once the hardware is done
with it: a double free.
The same path also drops a runtime PM reference that was never taken,
since pm_runtime_resume_and_get() releases its reference before
returning -EACCES.
Take the reference with pm_runtime_get_noresume() and resume with
pm_runtime_resume(), so that one reference is always held across the
send, and clear ret after the resume so that only a failure of the send
itself is reported.
-EACCES is only returned while runtime PM is disabled and the device is
not active. Not observed; found by review.
Fixes: 46e8f49ed7b3 ("net: wwan: t7xx: Introduce power management")
Signed-off-by: Tim JH Chen <tim770802@xxxxxxxxx>
---
drivers/net/wwan/t7xx/t7xx_hif_cldma.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wwan/t7xx/t7xx_hif_cldma.c b/drivers/net/wwan/t7xx/t7xx_hif_cldma.c
index e1b37deb6d9b..5b4b9ed4a95b 100644
--- a/drivers/net/wwan/t7xx/t7xx_hif_cldma.c
+++ b/drivers/net/wwan/t7xx/t7xx_hif_cldma.c
@@ -926,9 +926,17 @@ int t7xx_cldma_send_skb(struct cldma_ctrl *md_ctrl, int qno, struct sk_buff *skb
if (qno >= CLDMA_TXQ_NUM)
return -EINVAL;
- ret = pm_runtime_resume_and_get(md_ctrl->dev);
- if (ret < 0 && ret != -EACCES)
+ pm_runtime_get_noresume(md_ctrl->dev);
+ ret = pm_runtime_resume(md_ctrl->dev);
+ if (ret < 0 && ret != -EACCES) {
+ pm_runtime_put_noidle(md_ctrl->dev);
return ret;
+ }
+
+ /* ret holds the resume status (1 for an active device, -EACCES with
+ * runtime PM disabled), not the result of the send below.
+ */
+ ret = 0;
t7xx_pci_disable_sleep(md_ctrl->t7xx_dev);
queue = &md_ctrl->txq[qno];
--
2.43.0