public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: "Arve Hjønnevåg" <arve@android.com>,
	"Greg Kroah-Hartman" <gregkh@suse.de>
Subject: [PATCH 4/6] Staging: android: ram_console: Disable ECC when early init is enabled and validate buffer size
Date: Mon,  9 Feb 2009 11:34:04 -0800	[thread overview]
Message-ID: <1234208046-2295-4-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20090209193201.GB2194@kroah.com>

From: Arve Hjønnevåg <arve@android.com>

Signed-off-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/staging/android/Kconfig       |    1 +
 drivers/staging/android/ram_console.c |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig
index 6b996db..604bd1e 100644
--- a/drivers/staging/android/Kconfig
+++ b/drivers/staging/android/Kconfig
@@ -27,6 +27,7 @@ menuconfig ANDROID_RAM_CONSOLE_ERROR_CORRECTION
 	bool "Android RAM Console Enable error correction"
 	default n
 	depends on ANDROID_RAM_CONSOLE
+	depends on !ANDROID_RAM_CONSOLE_EARLY_INIT
 	select REED_SOLOMON
 	select REED_SOLOMON_ENC8
 	select REED_SOLOMON_DEC8
diff --git a/drivers/staging/android/ram_console.c b/drivers/staging/android/ram_console.c
index bf00685..643ac5c 100644
--- a/drivers/staging/android/ram_console.c
+++ b/drivers/staging/android/ram_console.c
@@ -224,9 +224,23 @@ static int __init ram_console_init(struct ram_console_buffer *buffer,
 	ram_console_buffer_size =
 		buffer_size - sizeof(struct ram_console_buffer);
 
+	if (ram_console_buffer_size > buffer_size) {
+		pr_err("ram_console: buffer %p, invalid size %d, datasize %d\n",
+		       buffer, buffer_size, ram_console_buffer_size);
+		return 0;
+	}
+
 #ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION
 	ram_console_buffer_size -= (DIV_ROUND_UP(ram_console_buffer_size,
 						ECC_BLOCK_SIZE) + 1) * ECC_SIZE;
+
+	if (ram_console_buffer_size > buffer_size) {
+		pr_err("ram_console: buffer %p, invalid size %d, "
+		       "non-ecc datasize %d\n",
+		       buffer, buffer_size, ram_console_buffer_size);
+		return 0;
+	}
+
 	ram_console_par_buffer = buffer->data + ram_console_buffer_size;
 
 
-- 
1.6.0.2


  parent reply	other threads:[~2009-02-09 19:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-09 19:32 [GIT PATCH] STAGING patches for 2.6-git Greg KH
2009-02-09 19:34 ` [PATCH 1/6] Revert Staging: at76_usb: update drivers/staging/at76_usb w/ mac80211 port Greg Kroah-Hartman
2009-02-09 19:34 ` [PATCH 2/6] Staging: at76_usb: fix bugs introduced by "Staging: at76_usb: cleanup dma on stack issues" Greg Kroah-Hartman
2009-02-09 19:34 ` [PATCH 3/6] Staging: at76_usb: Add support for OQO Model 01+ Greg Kroah-Hartman
2009-02-09 19:34 ` Greg Kroah-Hartman [this message]
2009-02-09 19:34 ` [PATCH 5/6] Staging: android: fix up units in timed_gpio Greg Kroah-Hartman
2009-02-09 19:34 ` [PATCH 6/6] Staging: panel: fix lcd panel driver build failure Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1234208046-2295-4-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=arve@android.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox