Skip to contentSkip to conversation

net: ipa: balance runtime PM reference on remove error

PATCH Applied Ruoyu Wang 2 participants 2 messages Aug 15 – Aug 20

Subsystems (3)
lore
Share & tools
lore

Ruoyu Wang

author
#0 lore raw

PATCH v2 1/1 net: ipa: balance runtime PM reference on remove error

ipa_remove() takes a runtime PM reference before accessing IPA hardware during teardown. If a concurrent modem start or stop keeps ipa_modem_stop() busy across both attempts, the callback intentionally returns without releasing the remaining resources because proceeding with teardown could crash. That return also skips the matching pm_runtime_put_noidle(), leaving the callback's usage-count reference held.

Drop only this runtime PM reference before returning. pm_runtime_put_noidle() does not request an idle transition, so the hardware and resources retained on this exceptional path remain untouched while the usage count stays balanced.

This issue was found by a static analysis checker and confirmed by manual source review.

Fixes 923a6b698447 ("net: ipa: get clock in ipa_probe()")
Assisted-by unnamed:gpt-5.5 typestate

---
Changes in v2:
- Simplify the teardown comment as requested.
- Add the Assisted-by tag.

v1: https://lore.kernel.org/r/[email protected]/

---
 drivers/net/ipa/ipa_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ipa/ipa_main.c +3 -3
index 788dd99af2a4dc..8d82fd5bb24b97 100644
@@ -969,12 +969,12 @@ static void ipa_remove(struct platform_device *pdev)
 		}
 		if (ret) {
 			/*
-			 * Not cleaning up here properly might also yield a
-			 * crash later on. As the device is still unregistered
-			 * in this case, this might even yield a crash later on.
+			 * Continuing teardown after failing to stop the modem
+			 * could crash, so leave the remaining resources allocated.
 			 */
 			dev_err(dev, "Failed to stop modem (%pe), leaking resources\n",
 				ERR_PTR(ret));
+			pm_runtime_put_noidle(dev);
 			return;
 		}
 
Signature · 1 line
2.51.0
#1 lore raw
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Sat, 15 Aug 2026 23:17:37 +0800 you wrote:

ipa_remove() takes a runtime PM reference before accessing IPA hardware during teardown. If a concurrent modem start or stop keeps ipa_modem_stop() busy across both attempts, the callback intentionally returns without releasing the remaining resources because proceeding with teardown could crash. That return also skips the matching pm_runtime_put_noidle(), leaving the callback's usage-count reference held.

[...]

Here is the summary with links:
- [net,v2] net: ipa: balance runtime PM reference on remove error

    https://git.kernel.org/netdev/net/c/6b9eaa61ff2d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html