]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
hwrng: core - Clean up RNG list when last hwrng is unregistered
authorGary R Hook <gary.hook@amd.com>
Fri, 15 Dec 2017 19:55:59 +0000 (13:55 -0600)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 22 Dec 2017 09:03:36 +0000 (20:03 +1100)
Commit 142a27f0a731 added support for a "best" RNG, and in doing so
introduced a hang from rmmod/modprobe -r when the last RNG on the list
was unloaded.

When the hwrng list is depleted, return the global variables to their
original state and decrement all references to the object.

Fixes: 142a27f0a731 ("hwrng: core - Reset user selected rng by writing "" to rng_current")
Signed-off-by: Gary R Hook <gary.hook@amd.com>
Reviewed-by: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/char/hw_random/core.c

index 657b8770b6b99e4c0c83e7b497b9bdec09463ca7..91bb98c42a1ca76376ae0db4b43fd7a89fca27b0 100644 (file)
@@ -306,6 +306,10 @@ static int enable_best_rng(void)
                ret = ((new_rng == current_rng) ? 0 : set_current_rng(new_rng));
                if (!ret)
                        cur_rng_set_by_user = 0;
+       } else {
+               drop_current_rng();
+               cur_rng_set_by_user = 0;
+               ret = 0;
        }
 
        return ret;