All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>,
	x86@kernel.org, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, rdunlap@infradead.org,
	linux-usb@vger.kernel.org
Subject: Re: [PATCH 3/3] usb: early: xhci-dbc: Fix xdbc number parsing
Date: Tue, 8 Mar 2022 12:01:03 +0200	[thread overview]
Message-ID: <4eda8138-76d0-e854-0ddb-8484e8ea283b@linux.intel.com> (raw)
In-Reply-To: <20220304152136.035911620@infradead.org>

On 4.3.2022 17.19, Peter Zijlstra wrote:
> kstrtoul() assumes the string contains the number only and is \0
> terminated, this is not the case, as such things like:
> 
> 	earlyprintk=xdbc1,keep
> 
> go completely sideways. Use simple_strtoul() instead.
> 
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
>  drivers/usb/early/xhci-dbc.c |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> --- a/drivers/usb/early/xhci-dbc.c
> +++ b/drivers/usb/early/xhci-dbc.c
> @@ -603,6 +603,7 @@ int __init early_xdbc_parse_parameter(ch
>  {
>  	unsigned long dbgp_num = 0;
>  	u32 bus, dev, func, offset;
> +	char *e;
>  	int ret;
>  
>  	if (!early_pci_allowed())
> @@ -613,8 +614,11 @@ int __init early_xdbc_parse_parameter(ch
>  	if (xdbc.xdbc_reg)
>  		return 0;
>  
> -	if (*s && kstrtoul(s, 0, &dbgp_num))
> -		dbgp_num = 0;
> +	if (*s) {

Do you think we need a code comment here stating something like
"use deprecated simple_strtoul() as kstrtoul can't handle characters after the number"

> +	       dbgp_num = simple_strtoul(s, &e, 10);
> +	       if (s == e)
> +		       dbgp_num = 0;
> +	}
>  

If not then PATCH 2/3 and 3/3 looks good to me
I don't know much about PATCH 1/3, the tsc change, but it didn't cause any issues for me either.

Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com>

Thanks
-Mathias

  reply	other threads:[~2022-03-08  9:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-04 15:19 [PATCH 0/3] x86: Make XDBC work Peter Zijlstra
2022-03-04 15:19 ` [PATCH 1/3] x86/tsc: Be consistent about use_tsc_delay() Peter Zijlstra
2022-03-04 15:19 ` [PATCH 2/3] usb: early: xhci-dbc: Remove duplicate keep parsing Peter Zijlstra
2022-03-04 15:19 ` [PATCH 3/3] usb: early: xhci-dbc: Fix xdbc number parsing Peter Zijlstra
2022-03-08 10:01   ` Mathias Nyman [this message]
2022-04-20  3:14 ` [PATCH 0/3] x86: Make XDBC work Randy Dunlap

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=4eda8138-76d0-e854-0ddb-8484e8ea283b@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rdunlap@infradead.org \
    --cc=x86@kernel.org \
    /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.