Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net: ipa: balance runtime PM reference on remove error
@ 2026-08-14 13:40 Ruoyu Wang
  2026-08-14 16:54 ` Alex Elder
  0 siblings, 1 reply; 2+ messages in thread
From: Ruoyu Wang @ 2026-08-14 13:40 UTC (permalink / raw)
  To: Alex Elder, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: netdev, linux-kernel, Ruoyu Wang

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()")
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
 drivers/net/ipa/ipa_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c
index 788dd99af2a4d..aab38fea91c61 100644
--- a/drivers/net/ipa/ipa_main.c
+++ b/drivers/net/ipa/ipa_main.c
@@ -975,6 +975,7 @@ static void ipa_remove(struct platform_device *pdev)
 			 */
 			dev_err(dev, "Failed to stop modem (%pe), leaking resources\n",
 				ERR_PTR(ret));
+			pm_runtime_put_noidle(dev);
 			return;
 		}
 
-- 
2.51.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] net: ipa: balance runtime PM reference on remove error
  2026-08-14 13:40 [PATCH net] net: ipa: balance runtime PM reference on remove error Ruoyu Wang
@ 2026-08-14 16:54 ` Alex Elder
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Elder @ 2026-08-14 16:54 UTC (permalink / raw)
  To: Ruoyu Wang, Alex Elder, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: netdev, linux-kernel

On 8/14/26 8:40 AM, Ruoyu Wang 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.

I concur that there should be a pm_runtime_put_noidle()
call before returning, to match the pm_runtime_get_sync()
earlier.

The exact code you're modifying here was added by commit
a92dbb9cdf046 ("net: ipa: Convert to platform remove
callback returning void"), but this particular error
was present before that.

The comment above this dev_err() call is rather confusing
and repetitive.  Could you try to clarify what it means,
or write your own simple explanation to replace it?

Otherwise, this looks like a good change to me.
Thank you very much.

Reviewed-by: Alex Elder <elder@riscstar.com>


> 
> 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()")
> Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
> ---
>   drivers/net/ipa/ipa_main.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c
> index 788dd99af2a4d..aab38fea91c61 100644
> --- a/drivers/net/ipa/ipa_main.c
> +++ b/drivers/net/ipa/ipa_main.c
> @@ -975,6 +975,7 @@ static void ipa_remove(struct platform_device *pdev)
>   			 */
>   			dev_err(dev, "Failed to stop modem (%pe), leaking resources\n",
>   				ERR_PTR(ret));
> +			pm_runtime_put_noidle(dev);
>   			return;
>   		}
>   


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-14 16:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-14 13:40 [PATCH net] net: ipa: balance runtime PM reference on remove error Ruoyu Wang
2026-08-14 16:54 ` Alex Elder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox