]> git.baikalelectronics.ru Git - kernel.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>
Wed, 13 Sep 2023 07:42:30 +0000 (09:42 +0200)
commit79a8ea5bf421bc3b71265ba1caddb88cb32d6422
treeb9e7a535cdb8c365e843dc1ecb9737a20bc55682
parent73d97508ab11a4986752e22e62b3c49213272c0f
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