Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2257433pxm; Fri, 4 Mar 2022 12:29:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFkZkz0Tv7CP2YUmGU5V3zCOQOr+IbrvUp6aREgXkuUDezYTxdcIBVyEeM7gEPxtDwBY14 X-Received: by 2002:a17:902:d48b:b0:151:a5a0:e117 with SMTP id c11-20020a170902d48b00b00151a5a0e117mr164380plg.119.1646425763324; Fri, 04 Mar 2022 12:29:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646425763; cv=none; d=google.com; s=arc-20160816; b=jTBhLXiNRrsZ6SUMe6Hh9En72QqaONhWKZkLfcUgw0doQveOdNNDSkbzzXUSnqfmPQ SQg+gxJ6aomreDfVjo3vV9GPMEkHPa9LaDX9LcPNty8xRGrtXUJeAsV1J+/RKm0ROZRz syE+/aqUfIwMSIv55/lBeYD/avIjQNeG11rfeBWfLRKm+MErLrj92sGXQSsLFo3dhAX7 2HZ4f44foFnNgw1cIQJsY9xKS8/lQWNxPWwAzqbmFnL2z42ggSuaA8lV9TfMOWmn2xeK gwuTmNu9z1Ifis2wjRf/3hZOg3sjBKL1VeT8FxISG7azbZRbXfyOvcKXx7VxCqk45jJj AJsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=QIlhvxTHHS/nanVwwxtHal6Wu98/SCmslE6BWXHduno=; b=eWRiwE7tokNHthRnXxOWtJQfmr6KhHM4kFnw9zpQq4HvG9IwOtvnAy2qV3XkSQG82K CuNEGHDzZ5iEfMhUujHUZ0h3UUejSQWVON393v3T5IwIg0f5l5mHInuf32NQKFoOrjwJ Jx/hhVQQq1Uf6a7V94Y8QFZM3k1BkTlyLcCwmH9QYvbRzc7aeTngwp2X0tyCb27H8406 pd+qCT+qxNCz6VCpzhsEBhNzUDNUxhUcOWmsF0qFuTNyN101iF/IMFbZxsgXSPNEp6P3 dVatnNffv2xx8Skvpfz6CEuhY1sn5KAhqXkx5OGGwbXEY4MCsO9nrhWAvNk4p9EoMzqF au/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=X6qLG+ac; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id oa14-20020a17090b1bce00b001bd14e0306dsi441898pjb.69.2022.03.04.12.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 12:29:23 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=X6qLG+ac; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4F684254A81; Fri, 4 Mar 2022 11:34:29 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240261AbiCDPX0 (ORCPT + 99 others); Fri, 4 Mar 2022 10:23:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240222AbiCDPXR (ORCPT ); Fri, 4 Mar 2022 10:23:17 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07DDD3880; Fri, 4 Mar 2022 07:22:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=QIlhvxTHHS/nanVwwxtHal6Wu98/SCmslE6BWXHduno=; b=X6qLG+ac8+En9eKNFpe+lA8tfA tgakWYuk8MeZZ7sI7+z0NuZXZ2XrIQu+i4DdINWK9aD+TIDms/Dg59lB2yGMx8GtCx3ug/okC3Ghf VFr9vCOdMpVwcyE3LExAIPfk8E8FwW5wncTwJx9Blm25+Qd/mEuTa0/11QDR3r8pBIK+kQwPD7TGS ZnS6KGd15FNfofasKdHqPsDl8ePIlPqC9QFxYj+MSWFv1mzlVmNTbd+F0sjJ4BUC7zq/8y8BV7RMY Ln74b7DK8Lpad8CIxczhTNSx5xCCOVGR3TFcQHg+Dfkbhs0G/Sr4fq8ebkFjxah2XV9yFKQtRmWMk UxFbVk9w==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQ9l3-00Cjnd-UU; Fri, 04 Mar 2022 15:22:18 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 88433300472; Fri, 4 Mar 2022 16:22:17 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 7111E2C546F85; Fri, 4 Mar 2022 16:22:17 +0100 (CET) Message-ID: <20220304152136.035911620@infradead.org> User-Agent: quilt/0.66 Date: Fri, 04 Mar 2022 16:19:56 +0100 From: Peter Zijlstra To: x86@kernel.org, mathias.nyman@linux.intel.com, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, rdunlap@infradead.org, linux-usb@vger.kernel.org Subject: [PATCH 3/3] usb: early: xhci-dbc: Fix xdbc number parsing References: <20220304151953.830111479@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) --- 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) { + dbgp_num = simple_strtoul(s, &e, 10); + if (s == e) + dbgp_num = 0; + } pr_notice("dbgp_num: %lu\n", dbgp_num);