hwrng: omap - fix runtime PM and clock leak on EPROBE_DEFER in probe
PATCH 1/1 hwrng: omap - fix runtime PM and clock leak on EPROBE_DEFER in probe
omap_rng_probe() calls pm_runtime_enable() and pm_runtime_resume_and_get() before requesting the optional "reg"/functional clocks. When either devm_clk_get() returns -EPROBE_DEFER, the probe bails out with a bare "return -EPROBE_DEFER;", bypassing the err_register cleanup that does pm_runtime_put_sync() + pm_runtime_disable() (and clk_disable_unprepare()).
As a result every probe deferral leaks a runtime PM usage count and leaves runtime PM enabled; the next probe attempt then hits an unbalanced pm_runtime_enable(). The second deferral point additionally leaks the already-enabled functional clock.
Redirect both -EPROBE_DEFER paths to err_register. clk_disable_unprepare() is a no-op for the NULL/ERR_PTR clocks on these early paths, so the cleanup is safe.
--- drivers/char/hw_random/omap-rng.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/char/hw_random/omap-rng.c +8 -4
@@ -459,8 +459,10 @@ static int omap_rng_probe(struct platform_device *pdev) } priv->clk =devm_clk_get (&pdev->dev,NULL ); -if (PTR_ERR (priv->clk) == -EPROBE_DEFER ) -return -EPROBE_DEFER ; +if (PTR_ERR (priv->clk) == -EPROBE_DEFER ) { + ret = -EPROBE_DEFER ; + goto err_register; + }if (!IS_ERR (priv->clk)) { ret =clk_prepare_enable (priv->clk);if (ret) {
@@ -471,8 +473,10 @@ static int omap_rng_probe(struct platform_device *pdev) } priv->clk_reg =devm_clk_get (&pdev->dev,"reg" ); -if (PTR_ERR (priv->clk_reg) == -EPROBE_DEFER ) -return -EPROBE_DEFER ; +if (PTR_ERR (priv->clk_reg) == -EPROBE_DEFER ) { + ret = -EPROBE_DEFER ; + goto err_register; + }if (!IS_ERR (priv->clk_reg)) { ret =clk_prepare_enable (priv->clk_reg);if (ret) {
Signature · 1 line
2.43.7
Herbert Xu
maintainerQuoted 15 lines · Peng Hao
omap_rng_probe()callspm_runtime_enable()andpm_runtime_resume_and_get()before requesting the optional "reg"/functional clocks. When eitherdevm_clk_get()returns -EPROBE_DEFER, the probe bails out with a bare "return -EPROBE_DEFER;", bypassing theerr_registercleanup that doespm_runtime_put_sync()+pm_runtime_disable()(andclk_disable_unprepare()).As a result every probe deferral leaks a runtime PM usage count and leaves runtime PM enabled; the next probe attempt then hits an unbalanced
pm_runtime_enable(). The second deferral point additionally leaks the already-enabled functional clock.Redirect both -EPROBE_DEFER paths to
err_register.clk_disable_unprepare()is a no-op for the NULL/ERR_PTR clocks on these early paths, so the cleanup is safe.
Quoted 5 lines
Fixes b166be004491 ("hwrng: omap - Fix clock resource by adding a register clock")Signed-off-by Peng Hao <[email protected]>---
drivers/char/hw_random/omap-rng.c| 12 ++++++++----1 file changed, 8 insertions(+), 4 deletions(-)
Your patch does not apply:
https://sashiko.dev/#/patchset/20260910112421.39372-1-flyingpeng%40tencent.com
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt