Commit ee410f15 authored by Thierry Escande's avatar Thierry Escande Committed by Linus Torvalds
Browse files

lib/test_printf.c: call wait_for_random_bytes() before plain %p tests

If the test_printf module is loaded before the crng is initialized, the
plain 'p' tests will fail because the printed address will not be hashed
and the buffer will contain '(ptrval)' instead.

This patch adds a call to wait_for_random_bytes() before plain 'p' tests
to make sure the crng is initialized.

Link: http://lkml.kernel.org/r/20180604113708.11554-1-thierry.escande@linaro.org

Signed-off-by: default avatarThierry Escande <thierry.escande@linaro.org>
Acked-by: default avatarTobin C. Harding <me@tobin.cc>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Cc: David Miller <davem@davemloft.net>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 608dbdfb
...@@ -260,6 +260,13 @@ plain(void) ...@@ -260,6 +260,13 @@ plain(void)
{ {
int err; int err;
/*
* Make sure crng is ready. Otherwise we get "(ptrval)" instead
* of a hashed address when printing '%p' in plain_hash() and
* plain_format().
*/
wait_for_random_bytes();
err = plain_hash(); err = plain_hash();
if (err) { if (err) {
pr_warn("plain 'p' does not appear to be hashed\n"); pr_warn("plain 'p' does not appear to be hashed\n");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment