Skip to content

Commit bc04a04

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
x86/mm: Fix cpumask_of_node() error condition
When CONFIG_DEBUG_PER_CPU_MAPS=y we validate that the @node argument of cpumask_of_node() is a valid node_id. It however forgets to check for negative numbers. Fix this by explicitly casting to unsigned int. (unsigned)node >= nr_node_ids verifies: 0 <= node < nr_node_ids Also ammend the error message to match the condition. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Yunsheng Lin <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent aeb415f commit bc04a04

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/mm/numa.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,9 +861,9 @@ void numa_remove_cpu(int cpu)
861861
*/
862862
const struct cpumask *cpumask_of_node(int node)
863863
{
864-
if (node >= nr_node_ids) {
864+
if ((unsigned)node >= nr_node_ids) {
865865
printk(KERN_WARNING
866-
"cpumask_of_node(%d): node > nr_node_ids(%u)\n",
866+
"cpumask_of_node(%d): (unsigned)node >= nr_node_ids(%u)\n",
867867
node, nr_node_ids);
868868
dump_stack();
869869
return cpu_none_mask;

0 commit comments

Comments
 (0)