mirror of
https://github.com/torvalds/linux.git
synced 2026-12-01 11:03:37 +00:00
can: gs_usb: gs_usb_receive_bulk_callback(): unanchor URL on usb_submit_urb() error
In commit7352e1d593("can: gs_usb: gs_usb_receive_bulk_callback(): fix URB memory leak"), the URB was re-anchored before usb_submit_urb() in gs_usb_receive_bulk_callback() to prevent a leak of this URB during cleanup. However, this patch did not take into account that usb_submit_urb() could fail. The URB remains anchored and usb_kill_anchored_urbs(&parent->rx_submitted) in gs_can_close() loops infinitely since the anchor list never becomes empty. To fix the bug, unanchor the URB when an usb_submit_urb() error occurs, also print an info message. Fixes:7352e1d593("can: gs_usb: gs_usb_receive_bulk_callback(): fix URB memory leak") Reported-by: Jakub Kicinski <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Link: https://patch.msgid.link/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]>
This commit is contained in:
@@ -754,6 +754,10 @@ resubmit_urb:
|
||||
usb_anchor_urb(urb, &parent->rx_submitted);
|
||||
|
||||
rc = usb_submit_urb(urb, GFP_ATOMIC);
|
||||
if (!rc)
|
||||
return;
|
||||
|
||||
usb_unanchor_urb(urb);
|
||||
|
||||
/* USB failure take down all interfaces */
|
||||
if (rc == -ENODEV) {
|
||||
@@ -762,6 +766,9 @@ device_detach:
|
||||
if (parent->canch[rc])
|
||||
netif_device_detach(parent->canch[rc]->netdev);
|
||||
}
|
||||
} else if (rc != -ESHUTDOWN && net_ratelimit()) {
|
||||
netdev_info(netdev, "failed to re-submit IN URB: %pe\n",
|
||||
ERR_PTR(urb->status));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user