Skip to content

Commit

Permalink
can: gs_usb: gs_usb_receive_bulk_callback(): count RX overflow errors…
Browse files Browse the repository at this point in the history
… also in case of OOM

[ Upstream commit 6c8bc15 ]

In case of an RX overflow error from the CAN controller and an OOM
where no skb can be allocated, the error counters are not incremented.

Fix this by first incrementing the error counters and then allocate
the skb.

Fixes: d08e973 ("can: gs_usb: Added support for the GS_USB CAN devices")
Link: https://lore.kernel.org/all/20230718-gs_usb-cleanups-v1-7-c3b9154ec605@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
marckleinebudde authored and gregkh committed Sep 13, 2023
1 parent ce60bfc commit 2dd5c7f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/net/can/usb/gs_usb.c
Expand Up @@ -626,15 +626,16 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
}

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

skb = alloc_can_err_skb(netdev, &cf);
if (!skb)
goto resubmit_urb;

cf->can_id |= CAN_ERR_CRTL;
cf->len = CAN_ERR_DLC;
cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW;
stats->rx_over_errors++;
stats->rx_errors++;
netif_rx(skb);
}

Expand Down

0 comments on commit 2dd5c7f

Please sign in to comment.