All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Ingo Molnar <mingo@kernel.org>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
	shuahkhan@gmail.com, tglx@linutronix.de
Subject: [tip:x86/platform] Revert "x86/early_printk: Replace obsolete simple_strtoul() usage with kstrtoint()"
Date: Sun, 22 Jul 2012 06:58:47 -0700	[thread overview]
Message-ID: <tip-36d93d88a5396baa135f8bcde7b8501dfe3b8e53@git.kernel.org> (raw)
In-Reply-To: <1338424803.3569.5.camel@lorien2>

Commit-ID:  36d93d88a5396baa135f8bcde7b8501dfe3b8e53
Gitweb:     http://git.kernel.org/tip/36d93d88a5396baa135f8bcde7b8501dfe3b8e53
Author:     Ingo Molnar <mingo@kernel.org>
AuthorDate: Fri, 22 Jun 2012 16:25:19 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Sun, 22 Jul 2012 15:47:52 +0200

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>
---
 arch/x86/kernel/early_printk.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
index 5e47712..9b9f18b 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)
 	unsigned char c;
 	unsigned divisor;
 	unsigned baud = DEFAULT_BAUD;
-	ssize_t ret;
+	char *e;
 
 	if (*s == ',')
 		++s;
@@ -127,14 +127,14 @@ static __init void early_serial_init(char *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];
 		}
@@ -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;
 	}
 

      parent reply	other threads:[~2012-07-22 13:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-27 16:48 [PATCH] x86: kernel/early_printk.c simple_strtoul cleanup Shuah Khan
2012-05-27 20:51 ` Joe Perches
2012-05-29 20:41   ` Shuah Khan
2012-05-31  0:40     ` [PATCH RESEND] " Shuah Khan
2012-06-06 15:15       ` [tip:x86/cleanups] x86/early_printk: Replace obsolete simple_strtoul() usage with kstrtoint() tip-bot for Shuah Khan
2012-06-22 14:24         ` Ingo Molnar
2012-06-25 17:17           ` Shuah Khan
2012-06-29 12:50             ` Ingo Molnar
2012-06-22 14:40       ` [tip:x86/cleanups] Revert "x86/early_printk: Replace obsolete simple_strtoul() usage with kstrtoint()" tip-bot for Ingo Molnar
2012-07-22 13:58       ` tip-bot for Ingo Molnar [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-36d93d88a5396baa135f8bcde7b8501dfe3b8e53@git.kernel.org \
    --to=mingo@kernel.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=shuahkhan@gmail.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.