Patchwork [2/3] powerpc: Check nvram_error_log_index in nvram_clear_error_log()

login
register
mail settings
Submitter Thomas Gleixner
Date Oct. 15, 2009, 8:54 a.m.
Message ID <20091015085329.210995619@linutronix.de>
Download mbox | patch
Permalink /patch/36089/
State Accepted
Commit fd62c6c448669a946e94fbb0ad179918b2233e3d
Delegated to: Benjamin Herrenschmidt
Headers show

Comments

Thomas Gleixner - Oct. 15, 2009, 8:54 a.m.
nvram_clear_error_log() calls ppc_md.nvram_write() even when
nvram_error_log_index is -1 (invalid). The nvram_write() function does
not check for a negative offset. 

Check nvram_error_log_index as the other nvram log functions do.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linuxppc-dev@ozlabs.org

---
 arch/powerpc/kernel/nvram_64.c |    3 +++
 1 file changed, 3 insertions(+)

Patch

Index: linux-2.6-tip/arch/powerpc/kernel/nvram_64.c
===================================================================
--- linux-2.6-tip.orig/arch/powerpc/kernel/nvram_64.c
+++ linux-2.6-tip/arch/powerpc/kernel/nvram_64.c
@@ -681,6 +681,9 @@  int nvram_clear_error_log(void)
 	int clear_word = ERR_FLAG_ALREADY_LOGGED;
 	int rc;
 
+	if (nvram_error_log_index == -1)
+		return -1;
+
 	tmp_index = nvram_error_log_index;
 	
 	rc = ppc_md.nvram_write((char *)&clear_word, sizeof(int), &tmp_index);