Commit e2971d1c authored by Werner Almesberger's avatar Werner Almesberger Committed by Linus Torvalds

[PATCH] round log buffer size to power of two

If setting the printk log buffer (with the boot command line option
"log_buf_len") to a value that's not a power of two, the index calculations
go wrong and yield confusing results.

This patch rounds the size to the next higher power of two.  It'll yield
garbage for sizes > INT_MAX bytes.
Signed-off-by: default avatarWerner Almesberger <werner@almesberger.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 053f6326
...@@ -192,6 +192,8 @@ static int __init log_buf_len_setup(char *str) ...@@ -192,6 +192,8 @@ static int __init log_buf_len_setup(char *str)
unsigned long size = memparse(str, &str); unsigned long size = memparse(str, &str);
unsigned long flags; unsigned long flags;
if (size)
size = roundup_pow_of_two(size);
if (size > log_buf_len) { if (size > log_buf_len) {
unsigned long start, dest_idx, offset; unsigned long start, dest_idx, offset;
char * new_log_buf; char * new_log_buf;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment