]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mm/vmalloc: fix incorrect size reporting on allocation failure
authorUladzislau Rezki (Sony) <urezki@gmail.com>
Mon, 2 Mar 2026 11:47:39 +0000 (12:47 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 5 Apr 2026 20:53:12 +0000 (13:53 -0700)
When __vmalloc_area_node() fails to allocate pages, the failure message
may report an incorrect allocation size, for example:

  vmalloc error: size 0, failed to allocate pages, ...

This happens because the warning prints area->nr_pages * PAGE_SIZE.  At
this point, area->nr_pages may be zero or partly populated thus it is not
valid.

Report the originally requested allocation size instead by using
nr_small_pages * PAGE_SIZE, which reflects the actual number of pages
being requested by user.

Link: https://lkml.kernel.org/r/20260302114740.2668450-1-urezki@gmail.com
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Reviewed-by: Mikulas Patocka <mpatocka@redhat.com>
Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/vmalloc.c

index b2c2ed650840ceda6d517e122675143b482d5f09..634d8c782ccaee541ef7d8326064b15e1a1490ab 100644 (file)
@@ -3894,7 +3894,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
                if (!fatal_signal_pending(current) && page_order == 0)
                        warn_alloc(gfp_mask, NULL,
                                "vmalloc error: size %lu, failed to allocate pages",
-                               area->nr_pages * PAGE_SIZE);
+                               nr_small_pages * PAGE_SIZE);
                goto fail;
        }