diff options
author | Dario Binacchi <dario.binacchi@amarulasolutions.com> | 2024-11-22 23:15:43 +0100 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2024-11-26 10:49:30 +0100 |
commit | ee6bf3677ae03569d833795064e17f605c2163c7 (patch) | |
tree | 71156d303a6a8776f5d296e808c788fe12ca5e77 /drivers/net/can | |
parent | can: c_can: c_can_handle_bus_err(): update statistics if skb allocation fails (diff) | |
download | linux-ee6bf3677ae03569d833795064e17f605c2163c7.tar.xz linux-ee6bf3677ae03569d833795064e17f605c2163c7.zip |
can: sun4i_can: sun4i_can_err(): call can_change_state() even if cf is NULL
Call the function can_change_state() if the allocation of the skb
fails, as it handles the cf parameter when it is null.
Additionally, this ensures that the statistics related to state error
counters (i. e. warning, passive, and bus-off) are updated.
Fixes: 0738eff14d81 ("can: Allwinner A10/A20 CAN Controller support - Kernel module")
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Link: https://patch.msgid.link/20241122221650.633981-3-dario.binacchi@amarulasolutions.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can')
-rw-r--r-- | drivers/net/can/sun4i_can.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c index 360158c295d3..17f94cca93fb 100644 --- a/drivers/net/can/sun4i_can.c +++ b/drivers/net/can/sun4i_can.c @@ -629,10 +629,10 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status) tx_state = txerr >= rxerr ? state : 0; rx_state = txerr <= rxerr ? state : 0; - if (likely(skb)) - can_change_state(dev, cf, tx_state, rx_state); - else - priv->can.state = state; + /* The skb allocation might fail, but can_change_state() + * handles cf == NULL. + */ + can_change_state(dev, cf, tx_state, rx_state); if (state == CAN_STATE_BUS_OFF) can_bus_off(dev); } |