From: Kevin Lourenco The computation: end = start + (size - (start_phys_aligned - start_phys)) / incr could theoretically underflow if size < offset, leading to a massive iteration. Add VM_WARN_ON_ONCE() to detect cases where the region size is smaller than the alignment offset. While this should never happen in practice due to memblock guarantees, the warning helps catch potential bugs in early memory initialization code. Suggested-by: Mike Rapoport Signed-off-by: Kevin Lourenco --- mm/memtest.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/memtest.c b/mm/memtest.c index c2c609c39119..bac195e6077a 100644 --- a/mm/memtest.c +++ b/mm/memtest.c @@ -46,6 +46,7 @@ static void __init memtest(u64 pattern, phys_addr_t start_phys, phys_addr_t size start_phys_aligned = ALIGN(start_phys, incr); start = __va(start_phys_aligned); + VM_WARN_ON_ONCE(size < start_phys_aligned - start_phys); end = start + (size - (start_phys_aligned - start_phys)) / incr; start_bad = 0; last_bad = 0; -- 2.47.3