Merge patch series "can: usb: f81604: handle short interrupt urb messages properly"

In this series Greg Kroah-Hartman takes the recent fixes on the gs_usb
driver and applies similar fixes to the f81604 driver.

Link: https://patch.msgid.link/2026022331-opal-evaluator-a928@gregkh
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
Marc Kleine-Budde 2026-03-02 11:04:38 +01:00
commit 6dfd65a69e

View File

@ -413,6 +413,7 @@ static void f81604_read_bulk_callback(struct urb *urb)
{
struct f81604_can_frame *frame = urb->transfer_buffer;
struct net_device *netdev = urb->context;
struct f81604_port_priv *priv = netdev_priv(netdev);
int ret;
if (!netif_device_present(netdev))
@ -445,10 +446,15 @@ static void f81604_read_bulk_callback(struct urb *urb)
f81604_process_rx_packet(netdev, frame);
resubmit_urb:
usb_anchor_urb(urb, &priv->urbs_anchor);
ret = usb_submit_urb(urb, GFP_ATOMIC);
if (!ret)
return;
usb_unanchor_urb(urb);
if (ret == -ENODEV)
netif_device_detach(netdev);
else if (ret)
else
netdev_err(netdev,
"%s: failed to resubmit read bulk urb: %pe\n",
__func__, ERR_PTR(ret));
@ -620,6 +626,12 @@ static void f81604_read_int_callback(struct urb *urb)
netdev_info(netdev, "%s: Int URB aborted: %pe\n", __func__,
ERR_PTR(urb->status));
if (urb->actual_length < sizeof(*data)) {
netdev_warn(netdev, "%s: short int URB: %u < %zu\n",
__func__, urb->actual_length, sizeof(*data));
goto resubmit_urb;
}
switch (urb->status) {
case 0: /* success */
break;
@ -646,10 +658,15 @@ static void f81604_read_int_callback(struct urb *urb)
f81604_handle_tx(priv, data);
resubmit_urb:
usb_anchor_urb(urb, &priv->urbs_anchor);
ret = usb_submit_urb(urb, GFP_ATOMIC);
if (!ret)
return;
usb_unanchor_urb(urb);
if (ret == -ENODEV)
netif_device_detach(netdev);
else if (ret)
else
netdev_err(netdev, "%s: failed to resubmit int urb: %pe\n",
__func__, ERR_PTR(ret));
}
@ -874,9 +891,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)