aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-10-19 23:10:44 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-10-19 23:10:44 +0200
commit8ee4ad719cb20f5347bc800c3b11dec94e7aed51 (patch)
treef78b266ba0f1fd51f5a9a16eeb1059c6f68e5e10
parentrandom: always call random ready function (diff)
downloadlinux-dev-jd/cleaner-add-random-ready.tar.xz
linux-dev-jd/cleaner-add-random-ready.zip
crypto/drbg: account for no longer returning -EALREADYjd/cleaner-add-random-ready
We now structure things in a way that assumes the seeding function is always eventually called. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--crypto/drbg.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/crypto/drbg.c b/crypto/drbg.c
index 70018397e59a..501e013cb96c 100644
--- a/crypto/drbg.c
+++ b/crypto/drbg.c
@@ -1411,18 +1411,8 @@ static int drbg_prepare_hrng(struct drbg_state *drbg)
err = add_random_ready_callback(&drbg->random_ready);
- switch (err) {
- case 0:
- break;
-
- case -EALREADY:
- err = 0;
- /* fall through */
-
- default:
- drbg->random_ready.func = NULL;
+ if (err)
return err;
- }
drbg->jent = crypto_alloc_rng("jitterentropy_rng", 0, 0);
@@ -1432,7 +1422,7 @@ static int drbg_prepare_hrng(struct drbg_state *drbg)
*/
drbg->reseed_threshold = 50;
- return err;
+ return 0;
}
/*
@@ -1526,9 +1516,9 @@ free_everything:
*/
static int drbg_uninstantiate(struct drbg_state *drbg)
{
- if (drbg->random_ready.func) {
- del_random_ready_callback(&drbg->random_ready);
- cancel_work_sync(&drbg->seed_work);
+ del_random_ready_callback(&drbg->random_ready);
+ cancel_work_sync(&drbg->seed_work);
+ if (drbg->jent) {
crypto_free_rng(drbg->jent);
drbg->jent = NULL;
}