From patchwork Mon Oct 16 13:09:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 153385 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3449013vqb; Mon, 16 Oct 2023 06:10:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEh6WeZKBXWCraiLpDQZ83ZDbo9cLZAOEEtOXGvblacQQu/3YUM/7mRcYgho7q8As1W9kd3 X-Received: by 2002:a05:6a00:3ab:b0:68f:c309:9736 with SMTP id y43-20020a056a0003ab00b0068fc3099736mr36490477pfs.3.1697461846328; Mon, 16 Oct 2023 06:10:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697461846; cv=none; d=google.com; s=arc-20160816; b=QSRPv4K6N4OzNN2oqCu2O4ayfXZn7JzLItLyFvVXAB0AGi0y14T2D0PcmufvRM3zyh 4Qc4GiqlUttatDM+GmSeKbUjUBAxGsgadlkFYQVXrbUUUcl2h3yuAWwZI+PkeCm6gcXr yfWMIgYAOZsHTPt6HGDeqkEgYigBuGltlkDieknVWwf+2C4lIRQ75xPt+8upVHEHeOU5 7tQdI012tFP2ATspBNl39aTjIMMzksCgfdggllB19O6RBzB1q+YVRoitTLpZp8UuYw6q rHTSyd2P7GCm41jzyzHgJbKA+YXuRkFyjgoeb255bPOFuIFr/VF9Ma9aWgIyJdNwJ+YT PEpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ulhm2LBLyfmwnnQN+Sxf+vbIgrbiGyy40ZAwnTq9h/c=; fh=YYrWResMAxfU+C17BdM7l/WUXXvK87rdz5rOaZ9UMD0=; b=QJfAx1doJee1x7E7kywOMsUNipO+TwoM8u5WEQXrU+0dx8tp4ABaQQp2LBs0CJ7tTn 8vb2Fu64WuVLDBVg7WTdox3IYdrVJ9ydriPfxBb7xqzoKFNcq+YsTfIk3iH6BmdKABl6 PpAw3mWyuv5Fl5x1J4CTt0/2MYtNNjNix33PWVSIunQUMuQpeYiithSlMcegZ4WQ7R2f 5yOw8aFzfm9mDUJQfY8j9UtvyxXOOF4ls8j3qTkT9ML2KA7Hp04mPyM69CcoVmB7RjbJ DuHV+/fSghB54FxkWCfjnS43iff+xIDdHL+zUJOwvIsO5V08Cyl2t/TvpRei2nZSyzDm SKnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AyDZbrFe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id v2-20020aa799c2000000b006bd2e896465si3882500pfi.199.2023.10.16.06.10.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 06:10:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AyDZbrFe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id A5B25803C5E1; Mon, 16 Oct 2023 06:10:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233370AbjJPNKU (ORCPT + 18 others); Mon, 16 Oct 2023 09:10:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233485AbjJPNJy (ORCPT ); Mon, 16 Oct 2023 09:09:54 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B76D10E; Mon, 16 Oct 2023 06:09:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697461792; x=1728997792; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=C2LXIp8aDjt+KK6t7A/TPFPz1sfKbc8zCp7ovuaeChc=; b=AyDZbrFeI4AILfaW/oI0CxrSL15v6TqHJfammDH5ah/akitmuh6JdDAZ 5/V6KEaXVZpE+UYi/GLy721r5ft+Ta2AjlsfCF2sWttbh/INi1g8rQbWV RURORGn0F0PP6zNx6Ph8lUbfJUtCMC3wlyW29Kvj31kJz4JJ9NrpG24+H fZsZRLysZYyeNgaFpMI+6jKstUk6D6G8c03iLQOC/Q0BtM3Oq+V0a+r/E WBLMp6jQW5T5O6YNUVfKtQ1wRCviI9MzeI/O6XsyaF/CD5/MV8JuxbV9m +LScTFS+a8obhAiTA3nQBNTxc03WpY/rziwvIMbvM1eG3s72wEgAGH4Dt Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="4133308" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="4133308" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 06:09:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="1087067149" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1087067149" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 16 Oct 2023 06:09:44 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 38F76A46; Mon, 16 Oct 2023 16:09:42 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Mathias Nyman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mathias Nyman , Greg Kroah-Hartman Subject: [PATCH v2 06/10] xhci: dbc: Don't shadow error codes in store() functions Date: Mon, 16 Oct 2023 16:09:30 +0300 Message-Id: <20231016130934.1158504-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231016130934.1158504-1-andriy.shevchenko@linux.intel.com> References: <20231016130934.1158504-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 16 Oct 2023 06:10:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779917752811563312 X-GMAIL-MSGID: 1779917752811563312 kstrtox() along with regmap API can return different error codes based on the circumstances. Don't shadow them when returning to the caller. Signed-off-by: Andy Shevchenko --- drivers/usb/host/xhci-dbgcap.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 6b9f4b839270..c211c69e8041 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -977,9 +977,11 @@ static ssize_t dbc_idVendor_store(struct device *dev, void __iomem *ptr; u16 value; u32 dev_info; + int ret; - if (kstrtou16(buf, 0, &value)) - return -EINVAL; + ret = kstrtou16(buf, 0, &value); + if (ret) + return ret; xhci = hcd_to_xhci(dev_get_drvdata(dev)); dbc = xhci->dbc; @@ -1017,9 +1019,11 @@ static ssize_t dbc_idProduct_store(struct device *dev, void __iomem *ptr; u32 dev_info; u16 value; + int ret; - if (kstrtou16(buf, 0, &value)) - return -EINVAL; + ret = kstrtou16(buf, 0, &value); + if (ret) + return ret; xhci = hcd_to_xhci(dev_get_drvdata(dev)); dbc = xhci->dbc; @@ -1056,9 +1060,11 @@ static ssize_t dbc_bcdDevice_store(struct device *dev, void __iomem *ptr; u32 dev_info; u16 value; + int ret; - if (kstrtou16(buf, 0, &value)) - return -EINVAL; + ret = kstrtou16(buf, 0, &value); + if (ret) + return ret; xhci = hcd_to_xhci(dev_get_drvdata(dev)); dbc = xhci->dbc; @@ -1098,9 +1104,13 @@ static ssize_t dbc_bInterfaceProtocol_store(struct device *dev, u8 value; int ret; - /* bInterfaceProtocol is 8 bit, but xhci only supports values 0 and 1 */ + /* bInterfaceProtocol is 8 bit, but... */ ret = kstrtou8(buf, 0, &value); - if (ret || value > 1) + if (ret) + return ret; + + /* ...xhci only supports values 0 and 1 */ + if (value > 1) return -EINVAL; xhci = hcd_to_xhci(dev_get_drvdata(dev));