linux/drivers/char/hw_random
Michael Büsch 837bf7cc3b hwrng: core - Always drop the RNG in hwrng_unregister()
enable_best_rng() is used in hwrng_unregister() to switch away from the
currently active RNG, if that is the one currently being removed.
However enable_best_rng() might fail, if the next RNG's init routine
fails. In that case enable_best_rng() will return an error code and
the currently active RNG will remain active.
After unregistering this might lead to crashes due to use-after-free.

Fix this by dropping the currently active RNG, if enable_best_rng()
failed. This will result in no RNG to be active, if the next-best
one failed to initialize.

This problem was introduced by 142a27f0a7

Fixes: 142a27f0a7 ("hwrng: core - Reset user selected rng by...")
Reported-by: Wirz <spam@lukas-wirz.de>
Tested-by: Wirz <spam@lukas-wirz.de>
Signed-off-by: Michael Büsch <m@bues.ch>
Cc: stable@vger.kernel.org
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-06-15 23:06:49 +08:00
..
Kconfig hwrng: stm32 - define default state for rng driver 2018-05-05 14:52:47 +08:00
Makefile hwrng: ks-sa - add hw_random driver 2018-03-23 23:40:08 +08:00
amd-rng.c
atmel-rng.c
bcm2835-rng.c hwrng: bcm2835 - Handle deferred clock properly 2018-02-22 22:16:21 +08:00
cavium-rng-vf.c hwrng: cavium - make two functions static 2018-03-09 22:45:34 +08:00
cavium-rng.c hwrng: cavium - make two functions static 2018-03-09 22:45:34 +08:00
core.c hwrng: core - Always drop the RNG in hwrng_unregister() 2018-06-15 23:06:49 +08:00
exynos-trng.c
geode-rng.c
hisi-rng.c
imx-rngc.c
intel-rng.c
iproc-rng200.c
ixp4xx-rng.c
ks-sa-rng.c hwrng: ks-sa - add hw_random driver 2018-03-23 23:40:08 +08:00
meson-rng.c
msm-rng.c
mtk-rng.c
mxc-rnga.c hwrng: mxc-rnga - add driver support on boards with device tree 2018-03-16 23:35:44 +08:00
n2-asm.S
n2-drv.c hwrng: n2 - fix spelling mistake: "restesting" -> "retesting" 2018-05-19 00:13:53 +08:00
n2rng.h
nomadik-rng.c
octeon-rng.c
omap-rng.c hwrng: omap - Fix clock resource by adding a register clock 2018-03-09 22:45:45 +08:00
omap3-rom-rng.c
pasemi-rng.c
pic32-rng.c
powernv-rng.c
pseries-rng.c
s390-trng.c
st-rng.c
stm32-rng.c hwrng: stm32 - fix pm_suspend issue 2018-05-05 14:52:49 +08:00
timeriomem-rng.c
tx4939-rng.c
via-rng.c hwrng: via - support new Centaur CPU 2018-04-21 00:59:03 +08:00
virtio-rng.c
xgene-rng.c