Skip to content

Commit b626070

Browse files
AlisonSchofielddjbw
authored andcommitted
x86/numa: Fix the sort compare func used in numa_fill_memblks()
The compare function used to sort memblks into starting address order fails when the result of its u64 address subtraction gets truncated to an int upon return. The impact of the bad sort is that memblks will be filled out incorrectly. Depending on the set of memblks, a user may see no errors at all but still have a bad fill, or see messages reporting a node overlap that leads to numa init failure: [] node 0 [mem: ] overlaps with node 1 [mem: ] [] No NUMA configuration found Replace with a comparison that can only result in: 1, 0, -1. Fixes: 8f012db ("x86/numa: Introduce numa_fill_memblks()") Signed-off-by: Alison Schofield <[email protected]> Acked-by: Dave Hansen <[email protected]> Reviewed-by: Dan Williams <[email protected]> Link: https://lore.kernel.org/r/99dcb3ae87e04995e9f293f6158dc8fa0749a487.1705085543.git.alison.schofield@intel.com Signed-off-by: Dan Williams <[email protected]>
1 parent 9b99c17 commit b626070

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/mm/numa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ static int __init cmp_memblk(const void *a, const void *b)
934934
const struct numa_memblk *ma = *(const struct numa_memblk **)a;
935935
const struct numa_memblk *mb = *(const struct numa_memblk **)b;
936936

937-
return ma->start - mb->start;
937+
return (ma->start > mb->start) - (ma->start < mb->start);
938938
}
939939

940940
static struct numa_memblk *numa_memblk_list[NR_NODE_MEMBLKS] __initdata;

0 commit comments

Comments
 (0)