From: OGAWA Hirofumi Date: Thu, 16 Nov 2006 09:19:29 +0000 (-0800) Subject: [PATCH] Fix strange size check in __get_vm_area_node() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=31be8309532a6743f301cb2e83bd12ca07988b09;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git [PATCH] Fix strange size check in __get_vm_area_node() Recently, __get_vm_area_node() was changed like following if (unlikely(!area)) return NULL; - if (unlikely(!size)) { - kfree (area); + if (unlikely(!size)) return NULL; - } It is leaking `area', also original code seems strange already. Probably, we wanted to do this patch. Signed-off-by: OGAWA Hirofumi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 7dc6aa745166..86897ee792d6 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -181,14 +181,13 @@ static struct vm_struct *__get_vm_area_node(unsigned long size, unsigned long fl } addr = ALIGN(start, align); size = PAGE_ALIGN(size); + if (unlikely(!size)) + return NULL; area = kmalloc_node(sizeof(*area), gfp_mask & GFP_LEVEL_MASK, node); if (unlikely(!area)) return NULL; - if (unlikely(!size)) - return NULL; - /* * We always allocate a guard page. */