Revert "x86/early_printk: Replace obsolete simple_strtoul() usage with kstrtoint()"

This reverts commit fbd24153c4.

This commit is subtly buggy: kstrto*int() can return an error but
it's not checked in every path. simple_strtoul() on the other hand
could not fail, so this patch subtly intruduces new failure modes.

Signed-off-by: Shuah Khan <shuahkhan@gmail.com>
Link: http://lkml.kernel.org/r/1338424803.3569.5.camel@lorien2
Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
Ingo Molnar 2012-06-22 16:25:19 +02:00
parent d872818dbb
commit 36d93d88a5

View File

@ -119,7 +119,7 @@ static __init void early_serial_init(char *s)
unsigned char c; unsigned char c;
unsigned divisor; unsigned divisor;
unsigned baud = DEFAULT_BAUD; unsigned baud = DEFAULT_BAUD;
ssize_t ret; char *e;
if (*s == ',') if (*s == ',')
++s; ++s;
@ -127,14 +127,14 @@ static __init void early_serial_init(char *s)
if (*s) { if (*s) {
unsigned port; unsigned port;
if (!strncmp(s, "0x", 2)) { if (!strncmp(s, "0x", 2)) {
ret = kstrtoint(s, 16, &early_serial_base); early_serial_base = simple_strtoul(s, &e, 16);
} else { } else {
static const int __initconst bases[] = { 0x3f8, 0x2f8 }; static const int __initconst bases[] = { 0x3f8, 0x2f8 };
if (!strncmp(s, "ttyS", 4)) if (!strncmp(s, "ttyS", 4))
s += 4; s += 4;
ret = kstrtouint(s, 10, &port); port = simple_strtoul(s, &e, 10);
if (ret || port > 1) if (port > 1 || s == e)
port = 0; port = 0;
early_serial_base = bases[port]; early_serial_base = bases[port];
} }
@ -149,8 +149,8 @@ static __init void early_serial_init(char *s)
outb(0x3, early_serial_base + MCR); /* DTR + RTS */ outb(0x3, early_serial_base + MCR); /* DTR + RTS */
if (*s) { if (*s) {
ret = kstrtouint(s, 0, &baud); baud = simple_strtoul(s, &e, 0);
if (ret || baud == 0) if (baud == 0 || s == e)
baud = DEFAULT_BAUD; baud = DEFAULT_BAUD;
} }