Skip to content

Commit

Permalink
random: use for_each_online_node() to iterate over NUMA nodes
Browse files Browse the repository at this point in the history
This fixes a crash on s390 with fake NUMA enabled.

Reported-by: Heiko Carstens <[email protected]>
Fixes: 1e7f583 ("random: make /dev/urandom scalable for silly userspace programs")
Signed-off-by: Theodore Ts'o <[email protected]>
  • Loading branch information
tytso committed Jul 28, 2016
1 parent 86a574d commit 59b8d4f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/char/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -1668,13 +1668,12 @@ static int rand_initialize(void)
#ifdef CONFIG_NUMA
pool = kmalloc(num_nodes * sizeof(void *),
GFP_KERNEL|__GFP_NOFAIL|__GFP_ZERO);
for (i=0; i < num_nodes; i++) {
for_each_online_node(i) {
crng = kmalloc_node(sizeof(struct crng_state),
GFP_KERNEL | __GFP_NOFAIL, i);
spin_lock_init(&crng->lock);
crng_initialize(crng);
pool[i] = crng;

}
mb();
crng_node_pool = pool;
Expand Down

0 comments on commit 59b8d4f

Please sign in to comment.