x86/tsc: Prevent NULL pointer deref in calibrate_delay_is_known()
authorThomas Gleixner <[email protected]>
Fri, 18 Mar 2016 07:35:29 +0000 (08:35 +0100)
committerThomas Gleixner <[email protected]>
Fri, 18 Mar 2016 13:51:06 +0000 (14:51 +0100)
commitf508a5ba7a4570418df6cfd68fe663ffdef2be63
tree2434d09f8cfadd8022470464529dae59483a214a
parent7834c10313fb823e538f2772be78edcdeed2e6e3
x86/tsc: Prevent NULL pointer deref in calibrate_delay_is_known()

The topology_core_cpumask is used to find a neighbour cpu in
calibrate_delay_is_known(). It might not be allocated at the first invocation
of that function on the boot cpu, when CONFIG_CPUMASK_OFFSTACK is set.

The mask is allocated later in native_smp_prepare_cpus. As a consequence the
underlying find_next_bit() call dereferences a NULL pointer.

Add a proper check to prevent this.

Fixes: c25323c07345 "x86/tsc: Use topology functions"
Reported-and-tested-by: Richard W.M. Jones <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Josh Boyer <[email protected]>
Link: http://lkml.kernel.org/r/alpine.DEB.2.11.1603180843270.3978@nanos
Signed-off-by: Thomas Gleixner <[email protected]>
arch/x86/kernel/tsc.c