]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/vmalloc: use kmalloc_array() instead of kmalloc()
authorMehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@gmail.com>
Sat, 18 Oct 2025 20:11:48 +0000 (21:11 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 22 Oct 2025 01:51:52 +0000 (18:51 -0700)
The number of NUMA nodes (nr_node_ids) is bounded, so overflow is not a
practical concern here.  However, using kmalloc_array() better reflects
the intent to allocate an array of unsigned ints, and improves consistency
with other NUMA-related allocations.

No functional change intended.

Link: https://lkml.kernel.org/r/20251018201207.27441-1-mehdi.benhadjkhelifa@gmail.com
Signed-off-by: Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@gmail.com>
Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Reviewed-by: Khalid Aziz <khalid@kernel.org>
Cc: David Hunter <david.hunter.linux@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/vmalloc.c

index 091a07f6d925245354c5784c39fe2c9a2a05ae88..adde450ddf5e2f86d36efedd1e23db496658f159 100644 (file)
@@ -5140,7 +5140,7 @@ static int vmalloc_info_show(struct seq_file *m, void *p)
        unsigned int *counters;
 
        if (IS_ENABLED(CONFIG_NUMA))
-               counters = kmalloc(nr_node_ids * sizeof(unsigned int), GFP_KERNEL);
+               counters = kmalloc_array(nr_node_ids, sizeof(unsigned int), GFP_KERNEL);
 
        for_each_vmap_node(vn) {
                spin_lock(&vn->busy.lock);