Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: return -ENOMEM for page-table allocation failure in insert_pages()
@ 2026-07-30  7:13 Avi Weiss
  2026-07-30  7:42 ` Lorenzo Stoakes (ARM)
  0 siblings, 1 reply; 7+ messages in thread
From: Avi Weiss @ 2026-07-30  7:13 UTC (permalink / raw)
  To: Andrew Morton
  Cc: David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett,
	Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
	Soheil Hassas Yeganeh, Arjun Roy, Eric Dumazet, linux-mm,
	linux-kernel, Avi Weiss

walk_to_pmd() returns NULL only when p4d_alloc(), pud_alloc(), or
pmd_alloc() fails. These are page-table allocation failures, but
insert_pages() currently reports them as -EFAULT.

Return -ENOMEM instead, consistent with the subsequent pte_alloc()
failure and with the single-page insert_page() path, which reports
failure of the same page-table allocation chain as -ENOMEM.

Address and range validation failures in vm_insert_pages() continue to
return -EFAULT. Keep the later -EFAULT return for
pte_offset_map_lock(), which is not an allocation failure.

Fixes: 8cd3984d81d5 ("mm/memory.c: add vm_insert_pages()")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
 mm/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memory.c b/mm/memory.c
index ff338c2abe92..d8eddca8e251 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2436,7 +2436,7 @@ static int insert_pages(struct vm_area_struct *vma, unsigned long addr,
 	unsigned long pages_to_write_in_pmd;
 	int ret;
 more:
-	ret = -EFAULT;
+	ret = -ENOMEM;
 	pmd = walk_to_pmd(mm, addr);
 	if (!pmd)
 		goto out;
-- 
2.43.0



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

end of thread, other threads:[~2026-07-30 16:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-30  7:13 [PATCH] mm: return -ENOMEM for page-table allocation failure in insert_pages() Avi Weiss
2026-07-30  7:42 ` Lorenzo Stoakes (ARM)
2026-07-30  7:43   ` Lorenzo Stoakes (ARM)
2026-07-30  8:27   ` David Hildenbrand (Arm)
2026-07-30  8:36     ` Lorenzo Stoakes (ARM)
2026-07-30 16:15   ` Andrew Morton
2026-07-30 16:27     ` Lorenzo Stoakes (ARM)

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