[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241122221650.633981-3-dario.binacchi@amarulasolutions.com>
Date: Fri, 22 Nov 2024 23:15:43 +0100
From: Dario Binacchi <dario.binacchi@...rulasolutions.com>
To: linux-kernel@...r.kernel.org
Cc: linux-amarula@...rulasolutions.com,
Dario Binacchi <dario.binacchi@...rulasolutions.com>,
Chen-Yu Tsai <wens@...e.org>,
Gerhard Bertelsmann <info@...hard-bertelsmann.de>,
Jernej Skrabec <jernej.skrabec@...il.com>,
Marc Kleine-Budde <mkl@...gutronix.de>,
Maxime Ripard <mripard@...nel.org>,
Samuel Holland <samuel@...lland.org>,
Vincent Mailhol <mailhol.vincent@...adoo.fr>,
linux-arm-kernel@...ts.infradead.org,
linux-can@...r.kernel.org,
linux-sunxi@...ts.linux.dev
Subject: [PATCH v2 02/12] can: sun4i_can: call can_change_state() even if cf is NULL
The function can_change_state() can also be called 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@...rulasolutions.com>
---
Changes in v2:
- Added in v2
drivers/net/can/sun4i_can.c | 8 ++++----
1 file 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);
}
--
2.43.0
Powered by blists - more mailing lists