aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2012-06-22 10:25:19 -0400
committerIngo Molnar <mingo@kernel.org>2012-07-22 09:47:52 -0400
commit36d93d88a5396baa135f8bcde7b8501dfe3b8e53 (patch)
tree05735ddf8bf7b1eb6d5a556b87ec7a6a792dcc89
parentd872818dbbeed1bccf58c7f8c7db432154c802f9 (diff)
Revert "x86/early_printk: Replace obsolete simple_strtoul() usage with kstrtoint()"
This reverts commit fbd24153c48b8425b09c161a020483cd77da870e. 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>
-rw-r--r--arch/x86/kernel/early_printk.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
index 5e4771266f1a..9b9f18b49918 100644
--- a/arch/x86/kernel/early_printk.c
+++ b/arch/x86/kernel/early_printk.c
@@ -119,7 +119,7 @@ static __init void early_serial_init(char *s)
119 unsigned char c; 119 unsigned char c;
120 unsigned divisor; 120 unsigned divisor;
121 unsigned baud = DEFAULT_BAUD; 121 unsigned baud = DEFAULT_BAUD;
122 ssize_t ret; 122 char *e;
123 123
124 if (*s == ',') 124 if (*s == ',')
125 ++s; 125 ++s;
@@ -127,14 +127,14 @@ static __init void early_serial_init(char *s)
127 if (*s) { 127 if (*s) {
128 unsigned port; 128 unsigned port;
129 if (!strncmp(s, "0x", 2)) { 129 if (!strncmp(s, "0x", 2)) {
130 ret = kstrtoint(s, 16, &early_serial_base); 130 early_serial_base = simple_strtoul(s, &e, 16);
131 } else { 131 } else {
132 static const int __initconst bases[] = { 0x3f8, 0x2f8 }; 132 static const int __initconst bases[] = { 0x3f8, 0x2f8 };
133 133
134 if (!strncmp(s, "ttyS", 4)) 134 if (!strncmp(s, "ttyS", 4))
135 s += 4; 135 s += 4;
136 ret = kstrtouint(s, 10, &port); 136 port = simple_strtoul(s, &e, 10);
137 if (ret || port > 1) 137 if (port > 1 || s == e)
138 port = 0; 138 port = 0;
139 early_serial_base = bases[port]; 139 early_serial_base = bases[port];
140 } 140 }
@@ -149,8 +149,8 @@ static __init void early_serial_init(char *s)
149 outb(0x3, early_serial_base + MCR); /* DTR + RTS */ 149 outb(0x3, early_serial_base + MCR); /* DTR + RTS */
150 150
151 if (*s) { 151 if (*s) {
152 ret = kstrtouint(s, 0, &baud); 152 baud = simple_strtoul(s, &e, 0);
153 if (ret || baud == 0) 153 if (baud == 0 || s == e)
154 baud = DEFAULT_BAUD; 154 baud = DEFAULT_BAUD;
155 } 155 }
156 156