summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2022-03-04 16:19:56 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-03-15 18:20:34 +0100
commit298ac860af9a0b604bcf06749a6acbd07548db99 (patch)
treea069ce7255282b46fa3691603ec72185ff8d9818
parentb0ae33a2d2fb6c55117b377ec4ae3f2c84eab6a2 (diff)
downloadlinux-298ac860af9a0b604bcf06749a6acbd07548db99.tar.gz
usb: early: xhci-dbc: Fix xdbc number parsing
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.

Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220304152136.035911620@infradead.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/early/xhci-dbc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c
index 100a45d26b5a..bfb7e2b85299 100644
--- a/drivers/usb/early/xhci-dbc.c
+++ b/drivers/usb/early/xhci-dbc.c
@@ -603,6 +603,7 @@ int __init early_xdbc_parse_parameter(char *s, int keep_early)
 {
 	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(char *s, int keep_early)
 	if (xdbc.xdbc_reg)
 		return 0;
 
-	if (*s && kstrtoul(s, 0, &dbgp_num))
-		dbgp_num = 0;
+	if (*s) {
+	       dbgp_num = simple_strtoul(s, &e, 10);
+	       if (s == e)
+		       dbgp_num = 0;
+	}
 
 	pr_notice("dbgp_num: %lu\n", dbgp_num);