Make sure that any calls to the cpumask API target a valid CPU. The CPU is identified by an int in the range [0, nr_cpus), where nr_cpus is set based on information in the DT. Signed-off-by: Nikos Nikoleris <nikos.nikoleris@xxxxxxx> --- lib/arm/asm/cpumask.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/arm/asm/cpumask.h b/lib/arm/asm/cpumask.h index 02124de..3fa57bf 100644 --- a/lib/arm/asm/cpumask.h +++ b/lib/arm/asm/cpumask.h @@ -20,26 +20,31 @@ typedef struct cpumask { static inline void cpumask_set_cpu(int cpu, cpumask_t *mask) { + assert(cpu >= 0 && cpu < nr_cpus); set_bit(cpu, cpumask_bits(mask)); } static inline void cpumask_clear_cpu(int cpu, cpumask_t *mask) { + assert(cpu >= 0 && cpu < nr_cpus); clear_bit(cpu, cpumask_bits(mask)); } static inline int cpumask_test_cpu(int cpu, const cpumask_t *mask) { + assert(cpu >= 0 && cpu < nr_cpus); return test_bit(cpu, cpumask_bits(mask)); } static inline int cpumask_test_and_set_cpu(int cpu, cpumask_t *mask) { + assert(cpu >= 0 && cpu < nr_cpus); return test_and_set_bit(cpu, cpumask_bits(mask)); } static inline int cpumask_test_and_clear_cpu(int cpu, cpumask_t *mask) { + assert(cpu >= 0 && cpu < nr_cpus); return test_and_clear_bit(cpu, cpumask_bits(mask)); } -- 2.25.1