Memory leak in 2.4 vmalloc.c get_vm_area

Nathan Scott (nathans@sgi.com)
Tue, 19 Nov 2002 10:32:02 +1100


hi Alan,

I noticed you recently merged this patch with Marcelo in the
2.4 BK tree (lists you as author, and annotation says it came
from DaveM originally)...

--- 1.10/mm/vmalloc.c Tue Feb 5 06:10:20 2002
+++ 1.11/mm/vmalloc.c Thu Sep 5 05:22:42 2002
@@ -177,6 +177,8 @@
if (!area)
return NULL;
size += PAGE_SIZE;
+ if(!size)
+ return NULL;
addr = VMALLOC_START;
write_lock(&vmlist_lock);
for (p = &vmlist; (tmp = *p) ; p = &tmp->next) {

This looks to me like it introduces a memory leak in the new !size
case - either the "size" bump and test needs to be moved before the
"area" kmalloc, or we need to kfree(area) before returning NULL.

If you like, I'll make a (trivial) patch to do one of these?

cheers.

-- 
Nathan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/