Skip to content

Commit 79a6d1b

Browse files
can: gs_usb: gs_usb_receive_bulk_callback(): unanchor URL on usb_submit_urb() error
In commit 7352e1d ("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: 7352e1d ("can: gs_usb: gs_usb_receive_bulk_callback(): fix URB memory leak") Reported-by: Jakub Kicinski <kuba@kernel.org> Closes: https://lore.kernel.org/all/20260110223836.3890248-1-kuba@kernel.org/ Link: https://patch.msgid.link/20260116-can_usb-fix-reanchor-v1-1-9d74e7289225@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
1 parent 375629c commit 79a6d1b

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

drivers/net/can/usb/gs_usb.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,10 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
754754
usb_anchor_urb(urb, &parent->rx_submitted);
755755

756756
rc = usb_submit_urb(urb, GFP_ATOMIC);
757+
if (!rc)
758+
return;
759+
760+
usb_unanchor_urb(urb);
757761

758762
/* USB failure take down all interfaces */
759763
if (rc == -ENODEV) {
@@ -762,6 +766,9 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
762766
if (parent->canch[rc])
763767
netif_device_detach(parent->canch[rc]->netdev);
764768
}
769+
} else if (rc != -ESHUTDOWN && net_ratelimit()) {
770+
netdev_info(netdev, "failed to re-submit IN URB: %pe\n",
771+
ERR_PTR(urb->status));
765772
}
766773
}
767774

0 commit comments

Comments
 (0)