Skip to contentSkip to conversation

Fix strange size check in __get_vm_area_node()

PATCH In review OGAWA Hirofumi 2 participants 2 messages Nov 15, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---

 mm/vmalloc.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
mm/vmalloc.c renamed from mm/vmalloc.c~vmalloc-leak-fix +2 -3
diff -puN mm/vmalloc.c~vmalloc-leak-fix mm/vmalloc.c
@@ -181,14 +181,13 @@ static struct vm_struct *__get_vm_area_n
 	}
 	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.
 	 */

_

Signature · 1 line
OGAWA Hirofumi <[email protected]>
#1 lore raw
Quoted 11 lines · OGAWA Hirofumi

Recently, __get_vm_area_node() was changed like following

(quoted diff) +1 -3
 	if (unlikely(!area))
 		return NULL;
 
-	if (unlikely(!size)) {
-		kfree (area);
+	if (unlikely(!size))
 		return NULL;
-	}
Quoted 3 lines

It is leaking `area', also original code seems strange already. Probably, we wanted to do this patch.

Indeed. I checked my original patch and it was correct. I dont know what happened then...

http://lkml.org/lkml/2006/10/23/86

Eric