]> granicus.if.org Git - spl/commitdiff
Fix out-of-bound in per_cpu in spl_random_init
authortuxoko <tuxoko@gmail.com>
Sat, 8 Oct 2016 03:59:46 +0000 (20:59 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Sat, 8 Oct 2016 03:59:46 +0000 (20:59 -0700)
When iterating per_cpu values, we need to use for_each_possible_cpu. While
NR_CPUS indicates the number of CPU supported by the kernel, it might not
initialize all of them if the kernel decides it's not possible to use them.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Closes #578

module/spl/spl-generic.c

index c04cb538c45a2c5dd25067306406143958549064..ce60963bd598b5e341bb313e5a0f77891f3b9d93 100644 (file)
@@ -638,7 +638,7 @@ spl_random_init(void)
                    "0x%016llx%016llx.", cpu_to_be64(s[0]), cpu_to_be64(s[1]));
        }
 
-       for (i = 0; i < NR_CPUS; i++) {
+       for_each_possible_cpu(i) {
                uint64_t *wordp = per_cpu(spl_pseudo_entropy, i);
 
                spl_rand_jump(s);