The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH net 1/2] fjes: unregister the netdev before destroying the workqueues
@ 2026-08-05  1:14 Fan Wu
  2026-08-05  1:23 ` [PATCH net 2/2] fjes: cancel force_close_task in fjes_remove() Fan Wu
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Fan Wu @ 2026-08-05  1:14 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, edumazet, pabeni, andrew+netdev, linux-kernel,
	stable, Fan Wu

fjes_remove() destroys the driver workqueues before unregistering the
netdev. The interrupt handler queues work on them, but the IRQ is only
freed from fjes_close() under unregister_netdev(), so an interrupt in that
window can queue work once the workqueues are gone.

Unregister the netdev first so fjes_close() frees the IRQ and cancels the
workers before the workqueues are destroyed. force_close_task, which the
workers arm on the system workqueue, is handled in the next patch.

This issue was found by an in-house static analysis tool.

Fixes: 658d439b2292 ("fjes: Introduce FUJITSU Extended Socket Network Device driver")
Cc: stable@vger.kernel.org
Assisted-by: Codex:gpt-5.6
Signed-off-by: Fan Wu <fanwu01@zju.edu.cn>
---
 drivers/net/fjes/fjes_main.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
index 1f0f38980..cddabc965 100644
--- a/drivers/net/fjes/fjes_main.c
+++ b/drivers/net/fjes/fjes_main.c
@@ -1394,17 +1394,14 @@ static void fjes_remove(struct platform_device *plat_dev)
 
 	fjes_dbg_adapter_exit(adapter);
 
-	cancel_delayed_work_sync(&adapter->interrupt_watch_task);
-	cancel_work_sync(&adapter->unshare_watch_task);
-	cancel_work_sync(&adapter->raise_intr_rxdata_task);
-	cancel_work_sync(&adapter->tx_stall_task);
+	/* Unregister first: .ndo_stop frees the IRQ and cancels the workers. */
+	unregister_netdev(netdev);
+
 	if (adapter->control_wq)
 		destroy_workqueue(adapter->control_wq);
 	if (adapter->txrx_wq)
 		destroy_workqueue(adapter->txrx_wq);
 
-	unregister_netdev(netdev);
-
 	fjes_hw_exit(hw);
 
 	netif_napi_del(&adapter->napi);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net 2/2] fjes: cancel force_close_task in fjes_remove()
  2026-08-05  1:14 [PATCH net 1/2] fjes: unregister the netdev before destroying the workqueues Fan Wu
@ 2026-08-05  1:23 ` Fan Wu
  2026-08-06 14:19   ` Simon Horman
  2026-08-06 14:19 ` [PATCH net 1/2] fjes: unregister the netdev before destroying the workqueues Simon Horman
  2026-08-06 16:50 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 5+ messages in thread
From: Fan Wu @ 2026-08-05  1:23 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, edumazet, pabeni, andrew+netdev, linux-kernel,
	stable, Fan Wu

force_close_task runs on the system workqueue, which destroy_workqueue()
does not drain, so it can run after free_netdev() and touch freed memory.
Cancel it after destroying the workqueues, before free_netdev().

This issue was found by an in-house static analysis tool.

Fixes: 658d439b2292 ("fjes: Introduce FUJITSU Extended Socket Network Device driver")
Cc: stable@vger.kernel.org
Assisted-by: Codex:gpt-5.6
Signed-off-by: Fan Wu <fanwu01@zju.edu.cn>
---
 drivers/net/fjes/fjes_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
index cddabc965..a2c77ca0d 100644
--- a/drivers/net/fjes/fjes_main.c
+++ b/drivers/net/fjes/fjes_main.c
@@ -1402,6 +1402,8 @@ static void fjes_remove(struct platform_device *plat_dev)
 	if (adapter->txrx_wq)
 		destroy_workqueue(adapter->txrx_wq);
 
+	cancel_work_sync(&adapter->force_close_task);
+
 	fjes_hw_exit(hw);
 
 	netif_napi_del(&adapter->napi);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net 2/2] fjes: cancel force_close_task in fjes_remove()
  2026-08-05  1:23 ` [PATCH net 2/2] fjes: cancel force_close_task in fjes_remove() Fan Wu
@ 2026-08-06 14:19   ` Simon Horman
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2026-08-06 14:19 UTC (permalink / raw)
  To: Fan Wu
  Cc: netdev, davem, kuba, edumazet, pabeni, andrew+netdev,
	linux-kernel, stable

On Wed, Aug 05, 2026 at 01:23:37AM +0000, Fan Wu wrote:
> force_close_task runs on the system workqueue, which destroy_workqueue()
> does not drain, so it can run after free_netdev() and touch freed memory.
> Cancel it after destroying the workqueues, before free_netdev().
> 
> This issue was found by an in-house static analysis tool.
> 
> Fixes: 658d439b2292 ("fjes: Introduce FUJITSU Extended Socket Network Device driver")
> Cc: stable@vger.kernel.org
> Assisted-by: Codex:gpt-5.6
> Signed-off-by: Fan Wu <fanwu01@zju.edu.cn>

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net 1/2] fjes: unregister the netdev before destroying the workqueues
  2026-08-05  1:14 [PATCH net 1/2] fjes: unregister the netdev before destroying the workqueues Fan Wu
  2026-08-05  1:23 ` [PATCH net 2/2] fjes: cancel force_close_task in fjes_remove() Fan Wu
@ 2026-08-06 14:19 ` Simon Horman
  2026-08-06 16:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2026-08-06 14:19 UTC (permalink / raw)
  To: Fan Wu
  Cc: netdev, davem, kuba, edumazet, pabeni, andrew+netdev,
	linux-kernel, stable

On Wed, Aug 05, 2026 at 01:14:09AM +0000, Fan Wu wrote:
> fjes_remove() destroys the driver workqueues before unregistering the
> netdev. The interrupt handler queues work on them, but the IRQ is only
> freed from fjes_close() under unregister_netdev(), so an interrupt in that
> window can queue work once the workqueues are gone.
> 
> Unregister the netdev first so fjes_close() frees the IRQ and cancels the
> workers before the workqueues are destroyed. force_close_task, which the
> workers arm on the system workqueue, is handled in the next patch.
> 
> This issue was found by an in-house static analysis tool.
> 
> Fixes: 658d439b2292 ("fjes: Introduce FUJITSU Extended Socket Network Device driver")
> Cc: stable@vger.kernel.org
> Assisted-by: Codex:gpt-5.6
> Signed-off-by: Fan Wu <fanwu01@zju.edu.cn>

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net 1/2] fjes: unregister the netdev before destroying the workqueues
  2026-08-05  1:14 [PATCH net 1/2] fjes: unregister the netdev before destroying the workqueues Fan Wu
  2026-08-05  1:23 ` [PATCH net 2/2] fjes: cancel force_close_task in fjes_remove() Fan Wu
  2026-08-06 14:19 ` [PATCH net 1/2] fjes: unregister the netdev before destroying the workqueues Simon Horman
@ 2026-08-06 16:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-08-06 16:50 UTC (permalink / raw)
  To: Fan Wu
  Cc: netdev, davem, kuba, edumazet, pabeni, andrew+netdev,
	linux-kernel, stable

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed,  5 Aug 2026 01:14:09 +0000 you wrote:
> fjes_remove() destroys the driver workqueues before unregistering the
> netdev. The interrupt handler queues work on them, but the IRQ is only
> freed from fjes_close() under unregister_netdev(), so an interrupt in that
> window can queue work once the workqueues are gone.
> 
> Unregister the netdev first so fjes_close() frees the IRQ and cancels the
> workers before the workqueues are destroyed. force_close_task, which the
> workers arm on the system workqueue, is handled in the next patch.
> 
> [...]

Here is the summary with links:
  - [net,1/2] fjes: unregister the netdev before destroying the workqueues
    https://git.kernel.org/netdev/net-next/c/f2473fbfc3fd
  - [net,2/2] fjes: cancel force_close_task in fjes_remove()
    https://git.kernel.org/netdev/net-next/c/c206fc0705d1

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-06 16:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-05  1:14 [PATCH net 1/2] fjes: unregister the netdev before destroying the workqueues Fan Wu
2026-08-05  1:23 ` [PATCH net 2/2] fjes: cancel force_close_task in fjes_remove() Fan Wu
2026-08-06 14:19   ` Simon Horman
2026-08-06 14:19 ` [PATCH net 1/2] fjes: unregister the netdev before destroying the workqueues Simon Horman
2026-08-06 16:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox