From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759077AbcILN1i (ORCPT ); Mon, 12 Sep 2016 09:27:38 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:53969 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759016AbcILN1e (ORCPT ); Mon, 12 Sep 2016 09:27:34 -0400 Subject: Re: [PATCH] serial: core: Fix handling of options after MMIO address To: Alexander Sverdlin , linux-kernel@vger.kernel.org References: <20160911004554.GA3562@roeck-us.net> <5e28d338-7667-f889-fae2-5aba0fdeb647@nokia.com> Cc: linux-serial@vger.kernel.org, Jiri Slaby , Greg Kroah-Hartman From: Guenter Roeck Message-ID: <82c71830-c19b-8eec-3281-13ee0f6514e4@roeck-us.net> Date: Mon, 12 Sep 2016 06:27:21 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <5e28d338-7667-f889-fae2-5aba0fdeb647@nokia.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: linux@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: linux@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/12/2016 04:29 AM, Alexander Sverdlin wrote: > Guenter Roeck reported a regression caused by commit "serial: earlycon: > Extend earlycon command line option to support 64-bit addresses": > > console= and earlycon= options have the following format: > ...,, > > Historically used here simple_strtoul() had no problems with comma, but the > new and recommended kstrtoull() requires null-terminated string and returns > -EINVAL in case there are "options" at the end. There is no recommended to > use function currently that will support it, so stick to obsolete > simple_strtoull() variant. > > Signed-off-by: Alexander Sverdlin > Reported-by: Guenter Roeck Reviewed-by: Guenter Roeck Tested-by: Guenter Roeck > --- > drivers/tty/serial/serial_core.c | 14 ++++++-------- > 1 file changed, 6 insertions(+), 8 deletions(-) > > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c > index 89f5d6a..f2c8a8d 100644 > --- a/drivers/tty/serial/serial_core.c > +++ b/drivers/tty/serial/serial_core.c > @@ -1938,14 +1938,11 @@ uart_get_console(struct uart_port *ports, int nr, struct console *co) > * console=,0x, > * is also accepted; the returned @iotype will be UPIO_MEM. > * > - * Returns 0 on success, -EINVAL or -ERANGE on failure > + * Returns 0 on success or -EINVAL on failure > */ > int uart_parse_earlycon(char *p, unsigned char *iotype, resource_size_t *addr, > char **options) > { > - int ret; > - unsigned long long tmp; > - > if (strncmp(p, "mmio,", 5) == 0) { > *iotype = UPIO_MEM; > p += 5; > @@ -1971,10 +1968,11 @@ int uart_parse_earlycon(char *p, unsigned char *iotype, resource_size_t *addr, > return -EINVAL; > } > > - ret = kstrtoull(p, 0, &tmp); > - if (ret) > - return ret; > - *addr = tmp; > + /* > + * Before you replace it with kstrtoull(), think about options separator > + * (',') it will not tolerate > + */ > + *addr = simple_strtoull(p, NULL, 0); > p = strchr(p, ','); > if (p) > p++; >