Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2341518pxb; Sun, 30 Jan 2022 12:51:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJzU4Zt2Rn4Ptz+osqvGlOMgaifpt00JpT40doec/c8dbZqrTP6Urv/lq9td3gxbsgpMF4lO X-Received: by 2002:aa7:ca04:: with SMTP id y4mr18350584eds.73.1643575905179; Sun, 30 Jan 2022 12:51:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643575905; cv=none; d=google.com; s=arc-20160816; b=WPEBdIRzpglPPsbqFzVHWjamIEWJOC2Ja7x0s0GJP4tdIWxj2iLvOKyqEIpCb/qon3 CXhFSKcJrUD+ZkCFL2Yn5yRL7wLUAJjMFl6KBnDyMqdLUS/00sAhZ+r7DfQKn9a11DVP QzyoVmCIcMNd3fegKb1xT5nC0d6d8Bom6lhv+L+Cl4ifEw1YQ2oUow/DlbcXkpgtdArB pOo6trL9JBcerXAAcgk5P9d5Kzd/PfGqde24Nn2Qd6M0UtOm4WCAujpxmMMfCIjrUBWI PL0wkudRNcwDrxB+dqPIyz1BjE7kMmoDNKodV2aZ692TSnU9Wi/GjYDZAAQ6Zd4W/DUN 0mWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to:dkim-signature; bh=+oCrJfL2Rg/oH0er7OSqjNKSnyrBGNnnhnM0hfBCHOg=; b=VJHHSqXag+pEq28w9FXEA69mPISk30zUe9Ns4E2rkylKa10kuem+5EolU1vR6bX+CY mDsbVOHPktGmoML6J0Bp2HulKEIbw3ELpQESY9WqMab6fJppvJybZHw3s696794raP3r FUo7gS9PsKKt09GX7V/uzd3KAiQnh35gOoeSPwpF8Fx70XAFYSJ84nSWCHSHHT7Dcs6t I+udaR92VW8W78ZKvwdoT46qcm1w1AgEEXxQLdRqfj5k2OGHAwFgTQ87+OidsheNIPyp oUMnQhTq29TasSxzx97/JpSyHIahFtmKJcosvodOXo2YedorU0Vh32DzocsRkHRdaL1g VCGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Qf3oLsjH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hv10si6484571ejc.657.2022.01.30.12.51.20; Sun, 30 Jan 2022 12:51:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Qf3oLsjH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347715AbiA1Jra (ORCPT + 99 others); Fri, 28 Jan 2022 04:47:30 -0500 Received: from mga03.intel.com ([134.134.136.65]:15409 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238349AbiA1Jra (ORCPT ); Fri, 28 Jan 2022 04:47:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643363250; x=1674899250; h=to:cc:references:from:subject:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=Fq9sQu/cN/lUsmIqrFTexk8KVRNWRRIf2vdhORwEjNA=; b=Qf3oLsjHRAf/su0eHffVmM+qMudN9axNyeuXp7+DAQV+kRHRJqrDie1n sOIjpUUpqFhBPBK37gBj+78iRis4+AUZA8hi8XttIlKnF8tJgXN1B68eu lNLmcBj6zo8aDfC6AidMgdWkRCfYFr+Ju9HgYHDsV21TGddo4CCRk9oDf NE/NSyvhnZjjautVbn17kCmZZAizxh4yVIw6tHNcWKYmgHYy/ZMQHcvEk 6iUXZr93l3uw2qfF0OWX79N8JG60Na63Iu02Dc7dy5QGkeHVRsWMC5XGj gZ9k/x+9NAbsHIY8T6t2FVCLlv7idYhs7fhv3Q07IPfjcVWdI6ljY4LYy Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10240"; a="247035970" X-IronPort-AV: E=Sophos;i="5.88,323,1635231600"; d="scan'208";a="247035970" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2022 01:47:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,323,1635231600"; d="scan'208";a="564147519" Received: from mattu-haswell.fi.intel.com (HELO [10.237.72.199]) ([10.237.72.199]) by orsmga001.jf.intel.com with ESMTP; 28 Jan 2022 01:47:26 -0800 To: =?UTF-8?B?6LCi5rOT5a6H?= , Greg KH Cc: Hongyu Xie , mathias.nyman@intel.com, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, 125707942@qq.com, stable@vger.kernel.org References: <20220126094126.923798-1-xy521521@gmail.com> <7af5b318-b1ac-0c74-1782-04ba50a3b5fa@linux.intel.com> From: Mathias Nyman Subject: Re: [PATCH -next] xhci: fix two places when dealing with return value of function xhci_check_args Message-ID: <6da59964-ce0e-c202-8a9c-a753a1908f3e@linux.intel.com> Date: Fri, 28 Jan 2022 11:48:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi On 28.1.2022 5.48, 谢泓宇 wrote: > Hi Mathias, > >> xhci_urb_enqueue() shouldn't be called for roothub urbs, but if it is then we >> should continue to return -EINVAL > > xhci_urb_enqueue() won't be called for roothub urbs, only for none roothub urbs(see usb_hcd_submit_urb()).> > So xhci_urb_enqueue() will not get 0 from xhci_check_args(). > > Still return -EINVAL if xhci_check_args() returns 0 in xhci_urb_enqueue()? > Yes. That is what it used to return. This is more about code maintaining practice than this specific patch. Only make the necessary change to fix a bug, especially if the patch is going to stable kernels. The change to return success ("0") instead of -EINVAL in xhci_urb_enqueue() for roothub URBs is irrelevant in fixing your issue. Debugging future issues is a lot harder when there are small undocumented unrelated functional changes scattered around bugfixing patches. Other reason is that even if you can be almost certain xhci_urb_enqueue() won't be called for roothub urbs for this kernel version, it's possible some old stable kernel code looks very different, and this change can break that stable version. Seemingly odd checks in code can indicate the old original code was flawed, and quickly worked around by adding the odd check. That kernel version might still depend on this odd check even if newer versions are fixed properly. >> >> xhci_check_args() should be rewritten later, but first we want a targeted fix >> that can go to stable. >> >> Your original patch would be ok after following modification: >> if (ret <= 0) >>     return ret ? ret : -EINVAL; > > I have two questions: > >     1) Why return -EINVAL for roothub urbs? - For all reasons stated above - Because it used to, and changing it doesn't fix anything - Because urbs sent to xhci_urb_enqueue() should have a valid urb->dev->parent, if they don't have it then they are INVALID > >     2) Should I change all the return statements about xhci_check_args() in drivers/usb/host/xhci.c? > >     There are 6 of them. Only make sure your patch doesn't change the functionality unnecessarily. There are two places where we return -EINVAL if xhci_check_args() returns 0: xhci_urb_enqueue() and xhci_check_streams_endpoint() Keep that functionality. Thanks Mathias