Skip to content

Commit 2148247

Browse files
Hongyu Xiegregkh
authored andcommitted
xhci: Prevent futile URB re-submissions due to incorrect return value.
commit 243a1dd upstream. The -ENODEV return value from xhci_check_args() is incorrectly changed to -EINVAL in a couple places before propagated further. xhci_check_args() returns 4 types of value, -ENODEV, -EINVAL, 1 and 0. xhci_urb_enqueue and xhci_check_streams_endpoint return -EINVAL if the return value of xhci_check_args <= 0. This causes problems for example r8152_submit_rx, calling usb_submit_urb in drivers/net/usb/r8152.c. r8152_submit_rx will never get -ENODEV after submiting an urb when xHC is halted because xhci_urb_enqueue returns -EINVAL in the very beginning. [commit message and header edit -Mathias] Fixes: 203a866 ("xhci: Avoid NULL pointer deref when host dies.") Cc: stable@vger.kernel.org Signed-off-by: Hongyu Xie <xiehongyu1@kylinos.cn> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20220215123320.1253947-3-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0b0a229 commit 2148247

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

drivers/usb/host/xhci.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,9 +1487,12 @@ static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
14871487
struct urb_priv *urb_priv;
14881488
int num_tds;
14891489

1490-
if (!urb || xhci_check_args(hcd, urb->dev, urb->ep,
1491-
true, true, __func__) <= 0)
1490+
if (!urb)
14921491
return -EINVAL;
1492+
ret = xhci_check_args(hcd, urb->dev, urb->ep,
1493+
true, true, __func__);
1494+
if (ret <= 0)
1495+
return ret ? ret : -EINVAL;
14931496

14941497
slot_id = urb->dev->slot_id;
14951498
ep_index = xhci_get_endpoint_index(&urb->ep->desc);
@@ -3289,7 +3292,7 @@ static int xhci_check_streams_endpoint(struct xhci_hcd *xhci,
32893292
return -EINVAL;
32903293
ret = xhci_check_args(xhci_to_hcd(xhci), udev, ep, 1, true, __func__);
32913294
if (ret <= 0)
3292-
return -EINVAL;
3295+
return ret ? ret : -EINVAL;
32933296
if (usb_ss_max_streams(&ep->ss_ep_comp) == 0) {
32943297
xhci_warn(xhci, "WARN: SuperSpeed Endpoint Companion"
32953298
" descriptor for ep 0x%x does not support streams\n",

0 commit comments

Comments
 (0)