If the USB device sends an invalid channel, consider this a firmware glitch
and don't detach all network interfaces of the USB device silently.
Instead, display an error message and resubmit the URB.
Link: https://patch.msgid.link/2026…@pengutronix.de
Signed-off-by: Marc Kleine-Budde <m…@pengutronix.de>
---
drivers/net/can/usb/gs_usb.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
index 40d867b830cf..a09cef3491bc 100644
--- a/drivers/net/can/usb/gs_usb.c
+++ b/drivers/net/can/usb/gs_usb.c
@@ -666,8 +666,13 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
}
/* device reports out of range channel id */
- if (hf->channel >= parent->channel_cnt)
- goto device_detach;
+ if (hf->channel >= parent->channel_cnt) {
+ dev_err_ratelimited(&parent->udev->dev,
+ "channel number out of range (channel=%u, channel_cnt=%u)\n",
+ hf->channel, parent->channel_cnt);
+
+ goto resubmit_urb;
+ }
dev = parent->canch[hf->channel];
@@ -792,7 +797,6 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
/* USB failure take down all interfaces */
if (rc == -ENODEV) {
-device_detach:
for (rc = 0; rc < parent->channel_cnt; rc++) {
if (parent->canch[rc])
netif_device_detach(parent->canch[rc]->netdev);
--
2.53.0