crypto: scompress - initialize per-CPU variables on each CPU
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Fri, 12 Apr 2019 15:14:15 +0000 (17:14 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 18 Apr 2019 14:15:04 +0000 (22:15 +0800)
In commit 71052dcf4be70 ("crypto: scompress - Use per-CPU struct instead
multiple variables") I accidentally initialized multiple times the memory on a
random CPU. I should have initialize the memory on every CPU like it has
been done earlier. I didn't notice this because the scheduler didn't
move the task to another CPU.
Guenter managed to do that and the code crashed as expected.

Allocate / free per-CPU memory on each CPU.

Fixes: 71052dcf4be70 ("crypto: scompress - Use per-CPU struct instead multiple variables")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/scompress.c

index da31f6f..712b4c2 100644 (file)
@@ -76,7 +76,7 @@ static void crypto_scomp_free_scratches(void)
        int i;
 
        for_each_possible_cpu(i) {
-               scratch = raw_cpu_ptr(&scomp_scratch);
+               scratch = per_cpu_ptr(&scomp_scratch, i);
 
                vfree(scratch->src);
                vfree(scratch->dst);
@@ -93,7 +93,7 @@ static int crypto_scomp_alloc_scratches(void)
        for_each_possible_cpu(i) {
                void *mem;
 
-               scratch = raw_cpu_ptr(&scomp_scratch);
+               scratch = per_cpu_ptr(&scomp_scratch, i);
 
                mem = vmalloc_node(SCOMP_SCRATCH_SIZE, cpu_to_node(i));
                if (!mem)