From 21f65bcd133178b6a0171cb0055a0e04092cc60a Mon Sep 17 00:00:00 2001 From: "Uladzislau Rezki (Sony)" Date: Mon, 12 Jul 2021 17:26:42 +0800 Subject: [PATCH] mm/vmalloc: use free_vm_area() if an allocation fails mainline inclusion from mainline-5.11-rc1 commit 8945a723064a2ccfc8dffa5dd17d5a3b351fbf1a category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I3ZGKZ CVE: NA ------------------------------------------------- There is a dedicated and separate function that finds and removes a continuous kernel virtual area. As a final step it also releases the "area", a descriptor of corresponding vm_struct. Use free_vmap_area() in the __vmalloc_node_range() instead of open coded steps which are exactly the same, to perform a cleanup. Link: https://lkml.kernel.org/r/20201116220033.1837-1-urezki@gmail.com Signed-off-by: Uladzislau Rezki (Sony) Cc: Hillf Danton Cc: Matthew Wilcox Cc: Michal Hocko Cc: Oleksiy Avramchenko Cc: Minchan Kim Cc: Steven Rostedt Cc: "Huang, Ying" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Chen Wandun Reviewed-by: Tong Tiangen Signed-off-by: Zheng Zengkai --- mm/vmalloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index b8f847a1f6e4..ef3ce845ae43 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2802,8 +2802,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, } if (!pages) { - remove_vm_area(area->addr); - kfree(area); + free_vm_area(area); return NULL; } -- GitLab