hwrng: ks-sa - Fix runtime PM cleanup on registration failure

ks_sa_rng_probe() enables runtime PM and resumes the device before
registering the hwrng. If devm_hwrng_register() fails, probe returns
without dropping the runtime PM usage count or disabling runtime PM.

Unwind the runtime PM state on the registration failure path, matching
the cleanup done by remove().

Fixes: eb428ee0e3 ("hwrng: ks-sa - add hw_random driver")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Yuho Choi
2026-07-02 19:39:21 -04:00
committed by Herbert Xu
parent 3b67be254b
commit 1c17b601fa

View File

@@ -242,7 +242,14 @@ static int ks_sa_rng_probe(struct platform_device *pdev)
return dev_err_probe(dev, ret, "Failed to enable SA power-domain\n");
}
return devm_hwrng_register(&pdev->dev, &ks_sa_rng->rng);
ret = devm_hwrng_register(dev, &ks_sa_rng->rng);
if (ret) {
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);
return ret;
}
return 0;
}
static void ks_sa_rng_remove(struct platform_device *pdev)