From: Werner Almesberger <werner@almesberger.net>

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: Werner Almesberger <werner@almesberger.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/kernel/printk.c |    2 ++
 1 files changed, 2 insertions(+)

diff -puN kernel/printk.c~round-log-buffer-size-to-power-of-two kernel/printk.c
--- 25/kernel/printk.c~round-log-buffer-size-to-power-of-two	2004-09-21 03:29:51.000000000 -0700
+++ 25-akpm/kernel/printk.c	2004-09-21 03:29:51.000000000 -0700
@@ -193,6 +193,8 @@ static int __init log_buf_len_setup(char
 	unsigned long size = memparse(str, &str);
 	unsigned long flags;
 
+	if (size)
+		size = roundup_pow_of_two(size);
 	if (size > log_buf_len) {
 		unsigned long start, dest_idx, offset;
 		char * new_log_buf;
_