Commit f0c74b6c authored by Mehdi Ben Hadj Khelifa's avatar Mehdi Ben Hadj Khelifa Committed by Andrew Morton
Browse files

mm/vmalloc: use kmalloc_array() instead of kmalloc()

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: default avatarMehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@gmail.com>
Reviewed-by: default avatarUladzislau Rezki (Sony) <urezki@gmail.com>
Reviewed-by: default avatarVishal Moola (Oracle) <vishal.moola@gmail.com>
Reviewed-by: default avatarKhalid Aziz <khalid@kernel.org>
Cc: David Hunter <david.hunter.linux@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 184c7533
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);