dmaengine: ti: edma: fix pm_runtime usage counter leak on error
Subsystems (2)
PATCH 1/2 dmaengine: ti: edma: fix pm_runtime usage counter leak on error
From: bui duc phuc <[email protected]>
pm_runtime_get_sync() leaves the runtime PM usage counter incremented even when it fails, but the error path in netcp_probe() does not call pm_runtime_put_noidle() to balance it, leaking a reference each time resume fails.
Use pm_runtime_resume_and_get() instead, which automatically drops the usage counter on failure, fixing the leak.
--- drivers/dma/ti/edma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/ti/edma.c +2 -2
@@ -2345,9 +2345,9 @@ static int edma_probe(struct platform_device *pdev)platform_set_drvdata (pdev, ecc);pm_runtime_enable (dev); - ret =pm_runtime_get_sync (dev); + ret =pm_runtime_resume_and_get (dev);if (ret <0 ) { -dev_err (dev,"pm_runtime_get_sync() failed\n" ); +dev_err (dev,"pm_runtime_resume_and_get() failed\n" );pm_runtime_disable (dev);return ret; }
Signature · 1 line
2.43.0
PATCH 2/2 dmaengine: ti: edma: Fix missing pm_runtime cleanup on probe failure
From: bui duc phuc <[email protected]>
pm_runtime_get_sync() errors were not checked, so on failure the usage count leaked and pm_runtime_enable() was never undone, leaving runtime PM in a half-initialized state after a failed probe.
Switch to pm_runtime_resume_and_get(), which cleans up the usage count internally on error, and call pm_runtime_disable() to balance the earlier pm_runtime_enable() on that path.
--- drivers/dma/ti/edma.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/dma/ti/edma.c +9 -1
@@ -2650,8 +2650,16 @@ static struct platform_driver edma_driver = {static int edma_tptc_probe (struct platform_device *pdev) { +int ret; +pm_runtime_enable (&pdev->dev); -return pm_runtime_get_sync (&pdev->dev); + ret =pm_runtime_resume_and_get (&pdev->dev); +if (ret <0 ) { +pm_runtime_disable (&pdev->dev); +return ret; + } + +return 0 ; }static struct platform_driver edma_tptc_driver = {
Signature · 1 line
2.43.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] dmaengine: commit message wrongly references netcp_probe() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] dmaengine: commit message wrongly references netcp_probe()
--
commit 46b6daf75a4d492c8e72053cb40b58c95d74f2fd
Author: bui duc phuc <[email protected]>
dmaengine: ti: edma: fix pm_runtime usage counter leak on error
This commit replaces pm_runtime_get_sync() with pm_runtime_resume_and_get() to prevent leaking a runtime PM usage counter reference on error paths.
Quoted 4 lines
pm_runtime_get_sync()leaves the runtime PM usage counter incremented even when it fails, but the error path innetcp_probe()does not callpm_runtime_put_noidle()to balance it, leaking a reference each time resume fails.
[Severity: Medium]
The commit message references netcp_probe(), but the patch actually modifies edma_probe() in drivers/dma/ti/edma.c. Could the commit message be updated to reflect the correct function name being patched?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 5 lines
[Severity: Medium]
The commit message referencesnetcp_probe(), but the patch actually modifiesedma_probe()indrivers/dma/ti/edma.c. Could the commit message be updated to reflect the correct function name being patched?
Yes, I will correct the function name in the next version.