Skip to content

Commit

Permalink
Revert "x86/early_printk: Replace obsolete simple_strtoul() usage wit…
Browse files Browse the repository at this point in the history
…h kstrtoint()"

This reverts commit fbd2415.

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 <[email protected]>
Link: http://lkml.kernel.org/r/1338424803.3569.5.camel@lorien2
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Ingo Molnar committed Jul 22, 2012
1 parent d872818 commit 36d93d8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions arch/x86/kernel/early_printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,22 @@ static __init void early_serial_init(char *s)
unsigned char c;
unsigned divisor;
unsigned baud = DEFAULT_BAUD;
ssize_t ret;
char *e;

if (*s == ',')
++s;

if (*s) {
unsigned port;
if (!strncmp(s, "0x", 2)) {
ret = kstrtoint(s, 16, &early_serial_base);
early_serial_base = simple_strtoul(s, &e, 16);
} else {
static const int __initconst bases[] = { 0x3f8, 0x2f8 };

if (!strncmp(s, "ttyS", 4))
s += 4;
ret = kstrtouint(s, 10, &port);
if (ret || port > 1)
port = simple_strtoul(s, &e, 10);
if (port > 1 || s == e)
port = 0;
early_serial_base = bases[port];
}
Expand All @@ -149,8 +149,8 @@ static __init void early_serial_init(char *s)
outb(0x3, early_serial_base + MCR); /* DTR + RTS */

if (*s) {
ret = kstrtouint(s, 0, &baud);
if (ret || baud == 0)
baud = simple_strtoul(s, &e, 0);
if (baud == 0 || s == e)
baud = DEFAULT_BAUD;
}

Expand Down

0 comments on commit 36d93d8

Please sign in to comment.