There are 2 BUG_ON() in the CAN dev helpers. During the update/test of the at91_can driver to rx-offload the one in can_restart() was triggered, due to a race condition in can_restart() and a hardware limitation of the at91_can IP core. This series fixes the race condition, replaces BUG_ON() with an error message, and does some cleanup. Finally, the BUG_ON() in can_put_echo_skb() is also replaced with error handling. Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> --- Changes in v2: - 4/5: move "Restarted" debug message and stats after successful restart (Thanks Vincent) - Link to v1: https://lore.kernel.org/all/20231004-can-dev-fix-can-restart-v1-0-2e52899eaaf5@xxxxxxxxxxxxxx --- Marc Kleine-Budde (5): can: dev: can_restart(): don't crash kernel if carrier is OK can: dev: can_restart(): fix race condition between controller restart and netif_carrier_on() can: dev: can_restart(): reverse logic to remove need for goto can: dev: can_restart(): update debug and error messages can: dev: can_put_echo_skb(): don't crash kernel if can_priv::echo_skb is accessed out of bounds drivers/net/can/dev/dev.c | 29 ++++++++++++++--------------- drivers/net/can/dev/skb.c | 6 +++++- 2 files changed, 19 insertions(+), 16 deletions(-) --- base-commit: 93e7eca853ca0087b129433630ddd89288d2b8b4 change-id: 20231004-can-dev-fix-can-restart-eef8ba3e5e6e Best regards, -- Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>