mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
Staging: android: ram_console: Disable ECC when early init is enabled and validate buffer size
Signed-off-by: Arve Hjønnevåg <arve@android.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
07f269862a
commit
5701c0519b
2 changed files with 15 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue