mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mm/vmalloc: bail out early on invalid page_shift in __vmap_pages_range_noflush()
@ 2026-10-03  9:04 Wen Jiang
  2026-10-03 10:02 ` Barry Song
  0 siblings, 1 reply; 3+ messages in thread
From: Wen Jiang @ 2026-10-03  9:04 UTC (permalink / raw)
  To: akpm
  Cc: urezki, dev.jain, baohua, linux-mm, linux-kernel, Wen Jiang, Wen Jiang

__vmap_pages_range_noflush() currently only warns when page_shift is
smaller than PAGE_SHIFT, then continues with the invalid shift. Return
-EINVAL instead so the bogus argument is caught immediately.

Suggested-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Signed-off-by: Wen Jiang <jiangwen6@xiaomi.com>
---
 mm/vmalloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index bea9f76ed7e7..838c8e0ccfe9 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -684,7 +684,8 @@ int __vmap_pages_range_noflush(unsigned long addr, unsigned long end,
 {
 	unsigned int i, nr = (end - addr) >> PAGE_SHIFT;
 
-	WARN_ON(page_shift < PAGE_SHIFT);
+	if (WARN_ON_ONCE(page_shift < PAGE_SHIFT))
+		return -EINVAL;
 
 	if (!IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMALLOC) ||
 			page_shift == PAGE_SHIFT)
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-03 14:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-03  9:04 [PATCH] mm/vmalloc: bail out early on invalid page_shift in __vmap_pages_range_noflush() Wen Jiang
2026-10-03 10:02 ` Barry Song
2026-10-03 14:55   ` Uladzislau Rezki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®