]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
can: usb: f81604: handle bulk write errors properly
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 23 Feb 2026 12:10:31 +0000 (13:10 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Mon, 2 Mar 2026 10:04:15 +0000 (11:04 +0100)
If a write urb fails then more needs to be done other than just logging
the message, otherwise the transmission could be stalled.  Properly
increment the error counters and wake up the queues so that data will
continue to flow.

Cc: Ji-Ze Hong (Peter Hong) <peter_hong@fintek.com.tw>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Vincent Mailhol <mailhol@kernel.org>
Cc: stable@kernel.org
Assisted-by: gkh_clanker_2000
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patch.msgid.link/2026022334-slackness-dynamic-9195@gregkh
Fixes: 88da17436973 ("can: usb: f81604: add Fintek F81604 support")
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/usb/f81604.c

index c61bd30d1765e61164add72df4c8b0b5590a6b1d..1cc927d79b6a54b08e9aba2e747c42c9ab51e223 100644 (file)
@@ -880,9 +880,27 @@ static void f81604_write_bulk_callback(struct urb *urb)
        if (!netif_device_present(netdev))
                return;
 
-       if (urb->status)
-               netdev_info(netdev, "%s: Tx URB error: %pe\n", __func__,
-                           ERR_PTR(urb->status));
+       if (!urb->status)
+               return;
+
+       switch (urb->status) {
+       case -ENOENT:
+       case -ECONNRESET:
+       case -ESHUTDOWN:
+               return;
+       default:
+               break;
+       }
+
+       if (net_ratelimit())
+               netdev_err(netdev, "%s: Tx URB error: %pe\n", __func__,
+                          ERR_PTR(urb->status));
+
+       can_free_echo_skb(netdev, 0, NULL);
+       netdev->stats.tx_dropped++;
+       netdev->stats.tx_errors++;
+
+       netif_wake_queue(netdev);
 }
 
 static void f81604_clear_reg_work(struct work_struct *work)