Re: [PATCH net v9 04/10] can: dev: check netif_running() before bus-off recovery

From: Cunhao Lu

Date: Fri Nov 13 2026 - 05:51:09 EST


Hi,

> [Severity: High]
> Can a restart worker pass this check and still restart the controller
> while ndo_stop() is running?

Yes. With restart-ms enabled, a worker can pass the running check before
close clears __LINK_STATE_START. FlexCAN calls close_candev() after
hardware and offload teardown, so an admitted worker can flush echo skbs
during teardown or restart an already stopped chip.

This race predates the patch. The running checks narrow the window but
do not serialize an already admitted callback with close. This patch
does not introduce or widen the race and does not fix that shutdown
ordering in other drivers. A complete fix must wait for active recovery
before dismantling its resources. The Rockchip follow-up patches address
that driver's shutdown ordering.

[Severity: High]
> Can restart_work still be queued after close_candev() has already
> cancelled it?

Yes. HI3110 calls close_candev() before free_irq(). Its IRQ thread can
sample the running state before close and enqueue after cancellation.
A fast reopen can then execute stale recovery and flush current echo
entries; removal can leave delayed work referring to freed can_priv.
Cleaning up the driver's private workqueue does not cancel the CAN core's
delayed work.

This producer/cancel ordering also predates the patch and is unchanged
by it. The running checks reduce recovery attempts but cannot protect
freed memory. Quiescing producers before the final cancellation, or
preventing late enqueues, requires a separate lifetime fix outside this
patch.

Best regards,
Cunhao Lu