linux/mm/memtest.c
Kevin Lourenco f56ccc3246 mm/memtest: add underflow detection for size calculation
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 <rppt@kernel.org>
Signed-off-by: Kevin Lourenco <klourencodev@gmail.com>
Link: https://patch.msgid.link/20251229161321.9079-1-klourencodev@gmail.com
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
2026-01-09 11:53:51 +02:00

139 lines
3.5 KiB