lkml.org 
[lkml]   [2018]   [Jan]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] hwrng: Explicitly drop current_rng when unregistering rng device
Date
When the currently in-use hw rng is being removed from the system,
explicitly drop it before using enable_best_rng as enable_best_rng
will not do anything if the list of avaialble RNGs is empty.

Without this, the last RNG removed from the system will never get
cleaned up and hwrng_unregister will hang.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
drivers/char/hw_random/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 657b8770b6b9..8df3f9f147e2 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -515,8 +515,10 @@ void hwrng_unregister(struct hwrng *rng)
mutex_lock(&rng_mutex);

list_del(&rng->list);
- if (current_rng == rng)
+ if (current_rng == rng) {
+ drop_current_rng();
enable_best_rng();
+ }

if (list_empty(&rng_list)) {
mutex_unlock(&rng_mutex);
--
2.15.1
\
 
 \ /
  Last update: 2018-01-31 00:26    [W:0.043 / U:2.496 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site