From 47ec77983887b37b81468422f28598a4c9e7019e Mon Sep 17 00:00:00 2001 From: Liu Ye Date: Mon, 3 Mar 2025 09:57:02 +0800 Subject: [PATCH] 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 Cc: Christop Hellwig Cc: "Uladzislau Rezki (Sony)" Signed-off-by: Andrew Morton --- mm/vmalloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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. -- 2.50.1