Skip to content

Commit fe5c994

Browse files
can: dev: can_restart(): don't crash kernel if carrier is OK
During testing, I triggered a can_restart() with the netif carrier being OK [1]. The BUG_ON, which checks if the carrier is OK, results in a fatal kernel crash. This is neither helpful for debugging nor for a production system. [1] The root cause is a race condition in can_restart() which will be fixed in the next patch. Do not crash the kernel, issue an error message instead, and continue restarting the CAN device anyway. Fixes: 39549ee ("can: CAN Network device driver and Netlink interface") Link: https://lore.kernel.org/all/20231005-can-dev-fix-can-restart-v2-1-91b5c1fd922c@pengutronix.de Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
1 parent 3b93334 commit fe5c994

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎drivers/net/can/dev/dev.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ static void can_restart(struct net_device *dev)
132132
struct can_frame *cf;
133133
int err;
134134

135-
BUG_ON(netif_carrier_ok(dev));
135+
if (netif_carrier_ok(dev))
136+
netdev_err(dev, "Attempt to restart for bus-off recovery, but carrier is OK?\n");
136137

137138
/* No synchronization needed because the device is bus-off and
138139
* no messages can come in or go out.

0 commit comments

Comments
 (0)