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

From: David Hildenbrand (Arm)

Date: Tue Aug 25 2026 - 06:43:26 EST


On 8/5/26 16:42, Avi Weiss wrote:
> populate_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.
>
> Signed-off-by: Avi Weiss <thnkslprpt@xxxxxxxxx>
> ---
> mm/memory.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memory.c b/mm/memory.c
> index 11bb4fb98761..16093479d341 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -2438,7 +2438,7 @@ static int insert_pages(struct vm_area_struct *vma, unsigned long addr,
> more:
> pmd = populate_to_pmd(mm, addr);
> if (!pmd) {
> - err = -EFAULT;
> + err = -ENOMEM;
> goto out;
> }
>

For this patch:

Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

--
Cheers,

David