]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
can: gs_usb: gs_usb_receive_bulk_callback(): count RX overflow errors also in case...
authorMarc Kleine-Budde <mkl@pengutronix.de>
Tue, 4 Jul 2023 09:23:37 +0000 (11:23 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Sep 2023 10:22:32 +0000 (12:22 +0200)
[ Upstream commit 6c8bc15f02b85bc8f47074110d8fd8caf7a1e42d ]

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: d08e973a77d1 ("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>
drivers/net/can/usb/gs_usb.c

index 5d6062fbebfcc1f157b7b0fe8745af18aa7511ee..7dc4fb574e459558baba3c8f9ef69a1cb3b158b1 100644 (file)
@@ -382,6 +382,9 @@ 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;
@@ -389,8 +392,6 @@ static void gs_usb_receive_bulk_callback(struct urb *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);
        }