padata: Check for valid cpumasks
authorSteffen Klassert <steffen.klassert@secunet.com>
Tue, 20 Jul 2010 06:51:25 +0000 (08:51 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 26 Jul 2010 06:13:58 +0000 (14:13 +0800)
Now that we allow to change the cpumasks from userspace, we have
to check for valid cpumasks in padata_do_parallel. This patch adds
the necessary check. This fixes a division by zero crash if the
parallel cpumask contains no active cpu.

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
kernel/padata.c

index 6a519454a5bd68d00ac1d1ea67f40ba79d5ccf49..7f895e2b4efb405f4b3d4de53dd5936a3d1c7d83 100644 (file)
@@ -114,7 +114,7 @@ int padata_do_parallel(struct padata_instance *pinst,
        pd = rcu_dereference(pinst->pd);
 
        err = -EINVAL;
-       if (!(pinst->flags & PADATA_INIT))
+       if (!(pinst->flags & PADATA_INIT) || pinst->flags & PADATA_INVALID)
                goto out;
 
        if (!cpumask_test_cpu(cb_cpu, pd->cpumask.cbcpu))