[PATCH net 1/3] net: atl1: disable work before freeing the netdev

From: BeaCox

Date: Wed Nov 04 2026 - 01:36:14 EST


atl1_remove() frees the netdev without disabling reset_dev_task or
link_chg_task. reset_dev_task is queued from the interrupt handler for
link-down and DMA errors and from atlx_tx_timeout(); link_chg_task is
queued from the interrupt handler when ISR_GPHY reports a link event.
Both callbacks dereference the adapter and the netdev, so a work that is
still pending or running after free_netdev() touches freed memory.

The original driver never cancelled these works, and the current
reset_dev_task was introduced when the two reset tasks were merged in
03662e41c7cf ("atl1: fix kernel panic in case of DMA errors").

Disable both works synchronously before unregistering the interface,
then delete the PHY configuration timer. disable_work_sync() drains a
queued or running instance and rejects a later queue_work(), which a
plain cancel_work_sync() would not. Deleting the timer after the works
have stopped also prevents a running link work from rearming it.
atl2_remove() cancels both works and deletes the timer before
unregistering for the same reason.

Fixes: f3cc28c79760 ("Add Attansic L1 ethernet driver.")
Cc: Chris Snook <chris.snook@xxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx # 6.10+
Signed-off-by: BeaCox <0xbeac@xxxxxxxxx>
---
drivers/net/ethernet/atheros/atlx/atl1.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/atheros/atlx/atl1.c b/drivers/net/ethernet/atheros/atlx/atl1.c
index 2883e9462f..2bd35c3cfc 100644
--- a/drivers/net/ethernet/atheros/atlx/atl1.c
+++ b/drivers/net/ethernet/atheros/atlx/atl1.c
@@ -3132,6 +3132,18 @@ static void atl1_remove(struct pci_dev *pdev)

adapter = netdev_priv(netdev);

+ /*
+ * reset_dev_task is queued from the interrupt handler and from the
+ * tx watchdog; link_chg_task is queued from the interrupt handler
+ * when ISR_GPHY reports a link event. Disable both before
+ * unregistering the interface so that neither a pending nor a late
+ * queue attempt can run after free_netdev().
+ */
+ disable_work_sync(&adapter->reset_dev_task);
+ disable_work_sync(&adapter->link_chg_task);
+ timer_delete_sync(&adapter->phy_config_timer);
+ adapter->phy_timer_pending = false;
+
/*
* Some atl1 boards lack persistent storage for their MAC, and get it
* from the BIOS during POST. If we've been messing with the MAC
--
2.43.0