hwrng: fetch randomness only after device init
authorAmit Shah <amit.shah@redhat.com>
Thu, 10 Jul 2014 10:12:34 +0000 (15:42 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 28 Jul 2014 15:08:27 +0000 (08:08 -0700)
commitf7eb924e4e591ead2e07dc9f2fabfaa5c4a6c31c
tree6fc672c7f8fc906cf21f37d30121556b94c012e2
parent6ffb863bbe53b5f0622b1a3f4797d4713721f9cb
hwrng: fetch randomness only after device init

commit d3cc7996473a7bdd33256029988ea690754e4e2a upstream.

Commit d9e7972619334 "hwrng: add randomness to system from rng sources"
added a call to rng_get_data() from the hwrng_register() function.
However, some rng devices need initialization before data can be read
from them.

This commit makes the call to rng_get_data() depend on no init fn
pointer being registered by the device.  If an init function is
registered, this call is made after device init.

CC: Kees Cook <keescook@chromium.org>
CC: Jason Cooper <jason@lakedaemon.net>
CC: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/hw_random/core.c