Re: [PATCH] mm: return -ENOMEM for page-table allocation failure in insert_pages()
From: Lorenzo Stoakes (ARM)
Date: Thu Jul 30 2026 - 04:44:46 EST
On Thu, Jul 30, 2026 at 10:27:20AM +0200, David Hildenbrand (Arm) wrote:
> On 7/30/26 09:42, 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).
>
> Agreed, I am missing the problem here?
Seems just a cleanup, I gave Avi some ideas ;) this function could do with
it.
>
> --
> Cheers,
>
> David
Cheers, Lorenzo