@@ -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));
}
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@arm.com> --- lib/arm/asm/cpumask.h | 5 +++++ 1 file changed, 5 insertions(+)