mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] UML - free wrapper fixes
@ 2004-09-23  2:20 Jeff Dike
  0 siblings, 0 replies; only message in thread
From: Jeff Dike @ 2004-09-23  2:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, blaisorblade_spam

__wrap_free is now careful about freeing to the same allocator that allocated
the buffer.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
Signed-off-by: Jeff Dike <jdike@addtoit.com>

Index: linux-2.6.9-rc2-mm1-orig/arch/um/kernel/main.c
===================================================================
--- linux-2.6.9-rc2-mm1-orig.orig/arch/um/kernel/main.c	2004-09-22 19:51:02.000000000 -0400
+++ linux-2.6.9-rc2-mm1-orig/arch/um/kernel/main.c	2004-09-22 20:07:02.000000000 -0400
@@ -220,14 +220,19 @@
 	 * If kmalloc is not yet possible, then the kernel memory regions
 	 * may not be set up yet, and the variables not initialized.  So,
 	 * 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);
-		else if((addr >= start_vm) && (addr <= end_vm))
+	}
+	else if((addr >= start_vm) && (addr < end_vm)){
+		if(CAN_KMALLOC())
 			vfree(ptr);
-		else
-			__real_free(ptr);
 	}
 	else __real_free(ptr);
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-09-23  1:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-23  2:20 [PATCH] UML - free wrapper fixes Jeff Dike

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®