[PATCH can-next 05/10] can: gs_usb: gs_usb_receive_bulk_callback(): check for overflow flag if SKB allocation fails

From: Marc Kleine-Budde

Date: Sat Oct 03 2026 - 18:55:58 EST


If the allocation of an SKB fails in gs_usb_receive_bulk_callback(), the
function does not check whether an overflow flag on the host frame is set.

Instead of directly resubmitting the URB, first check if an overflow flag
is set.

Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
---
drivers/net/can/usb/gs_usb.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
index 406c11efba79..01b4b6c980c9 100644
--- a/drivers/net/can/usb/gs_usb.c
+++ b/drivers/net/can/usb/gs_usb.c
@@ -658,7 +658,7 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
if (hf->flags & GS_CAN_FLAG_FD) {
skb = alloc_canfd_skb(netdev, &cfd);
if (!skb)
- goto resubmit_urb;
+ goto check_overflow;

cfd->can_id = le32_to_cpu(hf->can_id);
cfd->len = data_length;
@@ -671,7 +671,7 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
} else {
skb = alloc_can_skb(netdev, &cf);
if (!skb)
- goto resubmit_urb;
+ goto check_overflow;

cf->can_id = le32_to_cpu(hf->can_id);
can_frame_set_cc_len(cf, hf->can_dlc, dev->can.ctrlmode);
@@ -712,6 +712,7 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
netif_wake_queue(netdev);
}

+check_overflow:
if (hf->flags & GS_CAN_FLAG_OVERFLOW) {
stats->rx_over_errors++;
stats->rx_errors++;

--
2.53.0