Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1544432pxb; Tue, 8 Feb 2022 21:46:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5nSF7X88xJvZ6npRIGtKBQtGmFpkTc2S+lxXWwjseYsrTJLGLZHstj/sz/0+oyYSwrVUw X-Received: by 2002:a63:6842:: with SMTP id d63mr629653pgc.213.1644385591136; Tue, 08 Feb 2022 21:46:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644385591; cv=none; d=google.com; s=arc-20160816; b=aIwXw6JQDILNrF43qWUod9X5KiXyPH+TJ5lD+pOHDQbDH9VBQZkc4Vu0wJjqqoG86e VlryNihfJkEQ9902DWm8hVQ6vHx6olzyxzxDfYl+pXkUO+mhx/0q37kggi2xXetHcEtQ GC9Bk1RDEq8OAh/Jvu7Jg52rfvTipdVhzgu+x15DA2L4pffLhBhYqmgo8TT5kkF2GskO mbH38bpELIQzSkmoBzkkWIYkFDqfu8mBh/bEpTl8pGOhuKK1ZKPLhhOQDv7foIj/k8GN B62CMgwczB8bMSqzQemJYHuaFQOvFyts5fun4DutaSeZuOyVHsnC6URceoHWBeR+cm/n 8LrQ== 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=cKERDgM8wems4JtxHPyUkXSqWjVUzAXVpgH9qjLT5A4=; b=0fSNwu0FdJWdWPgKoWrUaFHxml0PGnm6xeVsZLpU/KtxTXOLpPjZPC0NyJdTq8/5yr czDLkeNC0wWuJZ2CieoVVu/KMfq7e1tftMfMai0HzbRM2mfECLGhXprlH/gAB3ZhuiwE JllMAS3YckTvra7nO5gYB38C/zeIQbsrJZLliew3wfp90PUk8CQ4xNsT7+cn4XZHbLif HkpDbTtAWye0z7JHTWZyGgJd9wFN5KnAFfabY6vYOfTB9+ttWxEAXezcFdVFluH8Z9kj rRoMc8L7yHadrarZH+03gy9yE/qE8B+AuucIt+EUWMLle6ep4ORoRqT/0+9DhOOnjQSi +DIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id w184si15196352pgd.90.2022.02.08.21.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 21:46:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 C8843C0045D2; Tue, 8 Feb 2022 21:42:20 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242661AbiBIDES (ORCPT + 99 others); Tue, 8 Feb 2022 22:04:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243525AbiBIDC1 (ORCPT ); Tue, 8 Feb 2022 22:02:27 -0500 X-Greylist: delayed 306 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 08 Feb 2022 19:02:22 PST Received: from nksmu.kylinos.cn (mailgw.kylinos.cn [123.150.8.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30527C0612B8; Tue, 8 Feb 2022 19:02:19 -0800 (PST) X-UUID: 1c6fefd360b84325acd0c6a5b21f4fbf-20220209 X-CPASD-INFO: a079444d41a24f238cb4d3f7f296489f@qoBxWWFmYpRgUaN-g6l9bViUkmSUX4a GqGxZZmJoZYaVhH5xTWJsXVKBfG5QZWNdYVN_eGpQYl9gZFB5i3-XblBgXoZgUZB3sHJxWWRiZA== X-CPASD-FEATURE: 0.0 X-CLOUD-ID: a079444d41a24f238cb4d3f7f296489f 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:189.0,IP:-2.0,MAL:0.0,ATTNUM:0 .0,PHF:-5.0,PHC:-5.0,SPF:4.0,EDMS:-3,IPLABEL:-2.0,FROMTO:0,AD:0,FFOB:0.0,CFOB :0.0,SPC:0.0,SIG:-5,AUF:14,DUF:32487,ACD:189,DCD:291,SL:0,AG:0,CFC:0.22,CFSR: 0.104,UAT:0,RAF:2,VERSION:2.3.4 X-CPASD-ID: 1c6fefd360b84325acd0c6a5b21f4fbf-20220209 X-CPASD-BLOCK: 1000 X-CPASD-STAGE: 1, 1 X-UUID: 1c6fefd360b84325acd0c6a5b21f4fbf-20220209 X-User: xiehongyu1@kylinos.cn Received: from [192.168.123.123] [(111.48.58.12)] by nksmu.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 128/128) with ESMTP id 1336843540; Wed, 09 Feb 2022 10:59:31 +0800 Message-ID: <4f1bd7fb-050b-ddb3-da69-1e6d32a5a7a1@kylinos.cn> Date: Wed, 9 Feb 2022 10:47:04 +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> <6da59964-ce0e-c202-8a9c-a753a1908f3e@linux.intel.com> From: =?UTF-8?B?6LCi5rOT5a6H?= In-Reply-To: <6da59964-ce0e-c202-8a9c-a753a1908f3e@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Hi Mathias, On 2022/1/28 17:48, Mathias Nyman wrote: > 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 I'll fix these in v2. Thanks Hongyu Xie