powerpc/nvram_64: Check nvram_error_log_index in nvram_clear_error_log()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Saturday, December 12, 2009 - 4:59 pm

Gitweb:     http://git.kernel.org/linus/fd62c6c448669a946e94fbb0ad179918b2233e3d
Commit:     fd62c6c448669a946e94fbb0ad179918b2233e3d
Parent:     ae7dd0208f62f1d6db4c49b85e54fa7bbed0ea4e
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Wed Oct 14 22:54:40 2009 +0000
Committer:  Benjamin Herrenschmidt <benh@kernel.crashing.org>
CommitDate: Fri Oct 30 17:21:28 2009 +1100

    powerpc/nvram_64: Check nvram_error_log_index in nvram_clear_error_log()
    
    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
    Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 arch/powerpc/kernel/nvram_64.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index c67e010..89d4af2 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/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);
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
powerpc/nvram_64: Check nvram_error_log_index in nvram_cle ..., Linux Kernel Mailing ..., (Sat Dec 12, 4:59 pm)