Commit 9b6da10c authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

[PATCH] uml: free wrapper fixes

__wrap_free is now careful about freeing to the same allocator that allocated
the buffer.
Signed-off-by: default avatarPaolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
Signed-off-by: default avatarJeff Dike <jdike@addtoit.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 9383a34c
...@@ -220,14 +220,19 @@ void __wrap_free(void *ptr) ...@@ -220,14 +220,19 @@ void __wrap_free(void *ptr)
* If kmalloc is not yet possible, then the kernel memory regions * If kmalloc is not yet possible, then the kernel memory regions
* may not be set up yet, and the variables not initialized. So, * may not be set up yet, and the variables not initialized. So,
* free is called. * free is called.
*
* CAN_KMALLOC is checked because it would be bad to free a buffer
* with kmalloc/vmalloc after they have been turned off during
* shutdown.
*/ */
if(CAN_KMALLOC()){
if((addr >= uml_physmem) && (addr <= high_physmem)) if((addr >= uml_physmem) && (addr < high_physmem)){
if(CAN_KMALLOC())
kfree(ptr); kfree(ptr);
else if((addr >= start_vm) && (addr <= end_vm)) }
else if((addr >= start_vm) && (addr < end_vm)){
if(CAN_KMALLOC())
vfree(ptr); vfree(ptr);
else
__real_free(ptr);
} }
else __real_free(ptr); else __real_free(ptr);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment