mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tim JH Chen <tim770802@gmail.com>
To: netdev@vger.kernel.org
Cc: chandrashekar.devegowda@intel.com, haijun.liu@mediatek.com,
	ricardo.martinez@linux.intel.com, loic.poulain@oss.qualcomm.com,
	ryazanov.s.a@gmail.com, johannes@sipsolutions.net,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com,
	ilpo.jarvinen@linux.intel.com,
	sreehari.kancharla@linux.intel.com,
	m.chetan.kumar@linux.intel.com, horms@kernel.org,
	linux-kernel@vger.kernel.org, tim.jh.chen@wnc.com.tw,
	Chih.Hung.Huang@wnc.com.tw, Tim JH Chen <tim770802@gmail.com>
Subject: [PATCH net v7 3/6] net: wwan: t7xx: fix skb double free when CLDMA send sees -EACCES
Date: Fri, 20 Nov 2026 09:55:53 +0800	[thread overview]
Message-ID: <20261120015556.131547-4-tim770802@gmail.com> (raw)
In-Reply-To: <20261120015556.131547-1-tim770802@gmail.com>

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@gmail.com>
---
 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


  parent reply	other threads:[~2026-11-20  1:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  1:55 [PATCH net v7 0/6] net: wwan: t7xx: fix TX push kthread soft lockup on suspend and RX stop issues Tim JH Chen
2026-11-20  1:55 ` [PATCH net v7 1/6] net: wwan: t7xx: fix TX push kthread soft lockup on system suspend Tim JH Chen
2026-11-20  1:55 ` [PATCH net v7 2/6] net: wwan: t7xx: fix runtime PM usage count underflow on -EACCES Tim JH Chen
2026-11-20  1:55 ` Tim JH Chen [this message]
2026-11-20  1:55 ` [PATCH net v7 4/6] net: wwan: t7xx: do not exit the TX push kthread on resume failure Tim JH Chen
2026-11-20  1:55 ` [PATCH net v7 5/6] net: wwan: t7xx: complete NAPI on the not-started RX poll early return Tim JH Chen
2026-11-20  1:55 ` [PATCH net v7 6/6] net: wwan: t7xx: fix memory ordering in t7xx_dpmaif_rx_stop() Tim JH Chen
2026-11-20  2:03 ` [PATCH net v7 0/6] net: wwan: t7xx: fix TX push kthread soft lockup on suspend and RX stop issues netdev-bot+sinfo

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=20261120015556.131547-4-tim770802@gmail.com \
    --to=tim770802@gmail.com \
    --cc=Chih.Hung.Huang@wnc.com.tw \
    --cc=andrew+netdev@lunn.ch \
    --cc=chandrashekar.devegowda@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=haijun.liu@mediatek.com \
    --cc=horms@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loic.poulain@oss.qualcomm.com \
    --cc=m.chetan.kumar@linux.intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ricardo.martinez@linux.intel.com \
    --cc=ryazanov.s.a@gmail.com \
    --cc=sreehari.kancharla@linux.intel.com \
    --cc=tim.jh.chen@wnc.com.tw \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®