From: Liu Ye <liuye@kylinos.cn> Date: Mon, 3 Mar 2025 01:57:02 +0000 (+0800) Subject: mm/vmalloc: move free_vm_area(area) from the __vmalloc_area_node function to the... X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=47ec77983887b37b81468422f28598a4c9e7019e;p=users%2Fjedix%2Flinux-maple.git mm/vmalloc: move free_vm_area(area) from the __vmalloc_area_node function to the __vmalloc_node_range_noprof function Moved free_vm_area from the __vmalloc_area_node function to the __vmalloc_node_range_noprof function so that allocation and freeing of the area can be paired in one function for better readability. Link: https://lkml.kernel.org/r/20250303015702.319416-1-liuye@kylinos.cn Signed-off-by: Liu Ye <liuye@kylinos.cn> Cc: Christop Hellwig <hch@infradead.org> Cc: "Uladzislau Rezki (Sony)" <urezki@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 61981ee1c9d2..76c101a55d81 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3651,7 +3651,6 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, warn_alloc(gfp_mask, NULL, "vmalloc error: size %lu, failed to allocated page array size %lu", nr_small_pages * PAGE_SIZE, array_size); - free_vm_area(area); return NULL; } @@ -3844,8 +3843,10 @@ again: /* Allocate physical pages and map them into vmalloc space. */ ret = __vmalloc_area_node(area, gfp_mask, prot, shift, node); - if (!ret) + if (!ret) { + free_vm_area(area); goto fail; + } /* * Mark the pages as accessible, now that they are mapped.