From: Wen Jiang <jiangwenxiaomi@gmail.com>
To: akpm@linux-foundation.org
Cc: urezki@gmail.com, dev.jain@arm.com, baohua@kernel.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Wen Jiang <jiangwenxiaomi@gmail.com>,
Wen Jiang <jiangwen6@xiaomi.com>
Subject: [PATCH] mm/vmalloc: bail out early on invalid page_shift in __vmap_pages_range_noflush()
Date: Sat, 3 Oct 2026 17:04:30 +0800 [thread overview]
Message-ID: <20261003090430.91664-1-jiangwenxiaomi@gmail.com> (raw)
__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
next reply other threads:[~2026-10-03 9:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-03 9:04 Wen Jiang [this message]
2026-10-03 10:02 ` Barry Song
2026-10-03 14:55 ` Uladzislau Rezki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261003090430.91664-1-jiangwenxiaomi@gmail.com \
--to=jiangwenxiaomi@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=dev.jain@arm.com \
--cc=jiangwen6@xiaomi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=urezki@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®