]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
hwrng: nomadik - keep clock enabled while hwrng is registered
authorMartin Kaiser <martin@kaiser.cx>
Sun, 2 Jul 2023 17:35:02 +0000 (19:35 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Sep 2023 10:22:32 +0000 (12:22 +0200)
commit5af3c8676b36c10c7e7b453cd86d31291c9cbf3b
tree188c76e172ffb91ef9e614a53938958b75d60c49
parent14c6d1e808475840b04279c786a51e248d1759d8
hwrng: nomadik - keep clock enabled while hwrng is registered

[ Upstream commit 039980de89dc9dd757418d6f296e4126cc3f86c3 ]

The nomadik driver uses devres to register itself with the hwrng core,
the driver will be unregistered from hwrng when its device goes out of
scope. This happens after the driver's remove function is called.

However, nomadik's clock is disabled in the remove function. There's a
short timeframe where nomadik is still registered with the hwrng core
although its clock is disabled. I suppose the clock must be active to
access the hardware and serve requests from the hwrng core.

Switch to devm_clk_get_enabled and let devres disable the clock and
unregister the hwrng. This avoids the race condition.

Fixes: 3e75241be808 ("hwrng: drivers - Use device-managed registration API")
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/char/hw_random/nomadik-rng.c