rtas_call uses kmalloc before the memory subsystem is up

Paul Mackerras paulus at samba.org
Mon Aug 16 15:18:19 EST 2004


Anton Blanchard writes:

> rtas_call is doing a kmalloc before the memory subsystem is up, but only
> when we hit an error.

This is a quick-n-dirty hack to fix the problem.  It's not completely
obvious what the proper solution looks like, unfortunately.

Paul.

diff -urN linux-2.5/arch/ppc64/kernel/rtas.c test25/arch/ppc64/kernel/rtas.c
--- linux-2.5/arch/ppc64/kernel/rtas.c	2004-08-03 08:07:43.000000000 +1000
+++ test25/arch/ppc64/kernel/rtas.c	2004-08-16 14:47:22.147162600 +1000
@@ -165,9 +165,12 @@

 	/* Log the error in the unlikely case that there was one. */
 	if (unlikely(logit)) {
-		buff_copy = kmalloc(RTAS_ERROR_LOG_MAX, GFP_ATOMIC);
-		if (buff_copy) {
-			memcpy(buff_copy, rtas_err_buf, RTAS_ERROR_LOG_MAX);
+		buff_copy = rtas_err_buf;
+		if (mem_init_done) {
+			buff_copy = kmalloc(RTAS_ERROR_LOG_MAX, GFP_ATOMIC);
+			if (buff_copy)
+				memcpy(buff_copy, rtas_err_buf,
+				       RTAS_ERROR_LOG_MAX);
 		}
 	}

@@ -176,7 +179,8 @@

 	if (buff_copy) {
 		log_error(buff_copy, ERR_TYPE_RTAS_LOG, 0);
-		kfree(buff_copy);
+		if (mem_init_done)
+			kfree(buff_copy);
 	}
 	return ret;
 }

** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc64-dev mailing list