Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1374210pxb; Sat, 29 Jan 2022 04:21:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJydjsGfJIe1Agh07iGPNIMFhKjaXeS5G7q4gW9ns56TKzvDcQiHs2VjwAK39V6iGAivyBYD X-Received: by 2002:a05:6402:40d0:: with SMTP id z16mr12174546edb.243.1643458918577; Sat, 29 Jan 2022 04:21:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643458918; cv=none; d=google.com; s=arc-20160816; b=QWKkSauQ3hUkuNMmRYdarB+iEs9V3kJli7U4f6Uf+tUGNmO3sAO0ATMwDipcMztSFE 5ahEYIj7fwok0RoldRQjuLELgcrCRetQ2woY+yxuUl9PVlHHQw2PPPPmAtst+Yv/SQQr +mWrB35O255Lt4oiQenyxDYdnBA8k2q11vnEjZOdb/xVcHfIiQ+DH+6z06WIGU1LzKLN iJfVB6cdECA6202qPqD3GZAgF+JwzXU0ia5DLnjo65JMRLeSthNeE9Yjc+O6mQ/7cCJf DSekQGhdYb9PhL5NXJO/8TFbjIKhom1H3Zty7X83T9cxZ/q86kddw7yId15yUZCm9LIs RXww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=fQDr5SDL7uwrJr6leigaRg1UxDhG/AA3rsg5tNVYzKw=; b=0fF6g5sX9qr3znzidHaa6MHPJg+eBzcI+oGiMvdtXeW09JjiTPatRRqEjz2L+lI6WQ Po/NVPvpIRXgCpbNsufkaDRpiGDZhGBR10vGtNfVMtc6jUXVBrQBGeWIq6wGu9JDxmzO zpqB4uvN9SdHCtX8jSlnyYUNXZeIC8J/6x8GIxUbVL31RsAIubd6B5nROVGgLp0mwQpI HmCvaAAc1dq2ScusbTmda7I2TE18ayy+eaBxq3mv1hjx/9u7h8xbC+rS2DrAFohg4W+P BgqSgUfZ75XCK+xlrsI7ADD+5WB+6VA/9gtEdyUsjwIA+dQa5PVs2NXda3sLCz2W0xms 3ugg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd19si790933ejc.732.2022.01.29.04.21.33; Sat, 29 Jan 2022 04:21:58 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345868AbiA1Dt0 (ORCPT + 99 others); Thu, 27 Jan 2022 22:49:26 -0500 Received: from mailgw.kylinos.cn ([123.150.8.42]:40173 "EHLO nksmu.kylinos.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1345802AbiA1DtZ (ORCPT ); Thu, 27 Jan 2022 22:49:25 -0500 X-UUID: facb723e0da54eb09d073fef8ee6ec25-20220128 X-CPASD-INFO: 70958ec4a68e43d3a33cd22ff1ff1fb9 @gIBzVWWXkWSNVnqxg3avbYFkY5OUXlK1qGuGll- WjlmVhH5xTWJsXVKBfG5QZWNdYVN_eGpQYl9gZFB5i3-XblBgXoZgUZB3hnJzVWiTkw== X-CPASD-FEATURE: 0.0 X-CLOUD-ID: 70958ec4a68e43d3a33cd22ff1ff1fb9 X-CPASD-SUMMARY: SIP:-1,APTIP:-2.0,KEY:0.0,FROMBLOCK:1,EXT:0.0,OB:0.0,URL:-5,T VAL:143.0,ESV:0.0,ECOM:-5.0,ML:0.0,FD:0.0,CUTS:198.0,IP:-2.0,MAL:0.0,ATTNUM:0 .0,PHF:-5.0,PHC:-5.0,SPF:4.0,EDMS:-3,IPLABEL:4480.0,FROMTO:0,AD:0,FFOB:0.0,CF OB:0.0,SPC:0.0,SIG:-5,AUF:13,DUF:32000,ACD:177,DCD:279,SL:0,AG:0,CFC:0.231,CF SR:0.192,UAT:0,RAF:2,VERSION:2.3.4 X-CPASD-ID: facb723e0da54eb09d073fef8ee6ec25-20220128 X-CPASD-BLOCK: 1000 X-CPASD-STAGE: 1, 1 X-UUID: facb723e0da54eb09d073fef8ee6ec25-20220128 X-User: xiehongyu1@kylinos.cn Received: from [172.20.4.10] [(116.128.244.169)] by nksmu.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 128/128) with ESMTP id 1692616607; Fri, 28 Jan 2022 12:01:59 +0800 Message-ID: Date: Fri, 28 Jan 2022 11:48:34 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH -next] xhci: fix two places when dealing with return value of function xhci_check_args Content-Language: en-US To: Mathias Nyman , 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: =?UTF-8?B?6LCi5rOT5a6H?= In-Reply-To: <7af5b318-b1ac-0c74-1782-04ba50a3b5fa@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mathias, On 2022/1/27 17:43, Mathias Nyman wrote: > On 26.1.2022 14.49, Hongyu Xie wrote: > >>> Anyway, why is this unique to this one driver?  Why does it not show up >>> for any other driver? >> The whole thing is not about a particular driver. The thing is xhci_urb_enqueue shouldn't change the return value of xhci_check_args from -ENODEV to -EINVAL. Many other drivers only check if the return value of xchi_check_args is <= 0. > Agree, lets return -ENODEV when appropriate. > >>>> The whole point is, if xhci_check_args returns value A, xhci_urb_enqueque >>>> shouldn't return any >>>> other value, because that will change some driver's behavior(like r8152.c). >>> But you are changing how the code currently works.  Are you sure you >>> want to have this "succeed" if this is on a root hub? >> Yes, I'm changing how the code currently works but not on a root hub. >>>> 2."So if 0 is returned, you will now return that here, is that ok? >>>> That is a change in functionality. >>>> But this can only ever be the case for a root hub, is that ok?" >>>> >>>> It's the same logic, but now xhci_urb_enqueue can return -ENODEV if xHC is >>>> halted. >>>> If it happens on a root hub,  xhci_urb_enqueue won't be called. >>>> >>>> 3."Again, this means all is good?  Why is this being called for a root hub?" >>>> >>>> It is the same logic with the old one, but now xhci_check_streams_endpoint >>>> can return -ENODEV if xHC is halted. >>> This still feels wrong to me, but I'll let the maintainer decide, as I >>> don't understand why a root hub is special here. >> Thanks please. usb_submit_urb will call usb_hcd_submit_urb. And usb_hcd_submit_urb will call rh_urb_enqueue if it's on a root hub instead of calling hcd->driver->urb_enqueue(which is xhci_urb_enqueue in this case). > 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()? > > 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?     2) Should I change all the return statements about xhci_check_args() in drivers/usb/host/xhci.c?     There are 6 of them. > > Thanks > -Mathias