Re: [PATCH] mm: return -ENOMEM for page-table allocation failure in insert_pages()

From: Lorenzo Stoakes (ARM)

Date: Thu Jul 30 2026 - 03:57:41 EST


On Thu, Jul 30, 2026 at 08:42:55AM +0100, Lorenzo Stoakes (ARM) wrote:
> On Thu, Jul 30, 2026 at 10:13:23AM +0300, Avi Weiss wrote:
> > 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()")
>
> Hmm :)
>
> This isn't really a fix. Anybody relying on this returning -ENOMEM
> vs. -EFAULT here is in a state of sin anyway (unless you can point to
> specific users who are broken).
>
> Drop the tag.
>
> > Signed-off-by: Avi Weiss <thnkslprpt@xxxxxxxxx>
>
> This is correct, walk

Ugh incomplete thought :)

->

This is correct, the 'walk' can only fail due to failure to allocate.

Anyway I gave you a bunch of stuff to do here, respin once you've addressed all
that.

Cheers, Lorenzo