Skip to content

Commit

Permalink
hwrng: core - Clean up RNG list when last hwrng is unregistered
Browse files Browse the repository at this point in the history
Commit 142a27f 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: 142a27f ("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>
  • Loading branch information
Gary R Hook authored and Herbert Xu committed Dec 22, 2017
1 parent 871df31 commit 0e4b529
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/char/hw_random/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0e4b529

Please sign in to comment.