From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: 谢泓宇 <xiehongyu1@kylinos.cn>, "Greg KH" <gregkh@linuxfoundation.org>
Cc: Hongyu Xie <xy521521@gmail.com>,
mathias.nyman@intel.com, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, 125707942@qq.com,
stable@vger.kernel.org
Subject: Re: [PATCH -next] xhci: fix two places when dealing with return value of function xhci_check_args
Date: Fri, 28 Jan 2022 11:48:57 +0200 [thread overview]
Message-ID: <6da59964-ce0e-c202-8a9c-a753a1908f3e@linux.intel.com> (raw)
In-Reply-To: <ce40f4cd-a110-80b1-f766-e94dd8cedc7e@kylinos.cn>
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
next prev parent reply other threads:[~2022-01-28 9:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-26 9:41 [PATCH -next] xhci: fix two places when dealing with return value of function xhci_check_args Hongyu Xie
2022-01-26 9:49 ` Greg KH
2022-01-26 10:22 ` 谢泓宇
2022-01-26 10:50 ` Greg KH
2022-01-26 12:49 ` Hongyu Xie
2022-01-27 9:43 ` Mathias Nyman
2022-01-28 3:48 ` 谢泓宇
2022-01-28 9:48 ` Mathias Nyman [this message]
2022-02-09 2:47 ` 谢泓宇
-- strict thread matches above, loose matches on Subject: below --
2022-01-26 8:56 Hongyu Xie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6da59964-ce0e-c202-8a9c-a753a1908f3e@linux.intel.com \
--to=mathias.nyman@linux.intel.com \
--cc=125707942@qq.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=stable@vger.kernel.org \
--cc=xiehongyu1@kylinos.cn \
--cc=xy521521@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).