All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 net] r8169: prevent potential deadlock in rtl8169_close
@ 2023-11-26 22:01 Heiner Kallweit
  2023-11-28 12:10 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Heiner Kallweit @ 2023-11-26 22:01 UTC (permalink / raw)
  To: Jakub Kicinski, Paolo Abeni, Eric Dumazet, David Miller,
	Realtek linux nic maintainers
  Cc: netdev

ndo_stop() is RTNL-protected by net core, and the worker function takes
RTNL as well. Therefore we will deadlock when trying to execute a
pending work synchronously. To fix this execute any pending work
asynchronously. This will do no harm because netif_running() is false
in ndo_stop(), and therefore the work function is effectively a no-op.
However we have to ensure that no task is running or pending after
rtl_remove_one(), therefore add a call to cancel_work_sync().

Fixes: abe5fc42f9ce ("r8169: use RTNL to protect critical sections")
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
v2:
- add call to cancel_work_sync() in rtl_remove_one()
---
 drivers/net/ethernet/realtek/r8169_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 0aed99a20..dd04c6358 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -4603,7 +4603,7 @@ static int rtl8169_close(struct net_device *dev)
 	rtl8169_down(tp);
 	rtl8169_rx_clear(tp);
 
-	cancel_work_sync(&tp->wk.work);
+	cancel_work(&tp->wk.work);
 
 	free_irq(tp->irq, tp);
 
@@ -4837,6 +4837,8 @@ static void rtl_remove_one(struct pci_dev *pdev)
 	if (pci_dev_run_wake(pdev))
 		pm_runtime_get_noresume(&pdev->dev);
 
+	cancel_work_sync(&tp->wk.work);
+
 	unregister_netdev(tp->dev);
 
 	if (tp->dash_type != RTL_DASH_NONE)
-- 
2.43.0

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

* Re: [PATCH v2 net] r8169: prevent potential deadlock in rtl8169_close
  2023-11-26 22:01 [PATCH v2 net] r8169: prevent potential deadlock in rtl8169_close Heiner Kallweit
@ 2023-11-28 12:10 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-11-28 12:10 UTC (permalink / raw)
  To: Heiner Kallweit; +Cc: kuba, pabeni, edumazet, davem, nic_swsd, netdev

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Sun, 26 Nov 2023 23:01:02 +0100 you wrote:
> ndo_stop() is RTNL-protected by net core, and the worker function takes
> RTNL as well. Therefore we will deadlock when trying to execute a
> pending work synchronously. To fix this execute any pending work
> asynchronously. This will do no harm because netif_running() is false
> in ndo_stop(), and therefore the work function is effectively a no-op.
> However we have to ensure that no task is running or pending after
> rtl_remove_one(), therefore add a call to cancel_work_sync().
> 
> [...]

Here is the summary with links:
  - [v2,net] r8169: prevent potential deadlock in rtl8169_close
    https://git.kernel.org/netdev/net/c/91d3d149978b

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] 2+ messages in thread

end of thread, other threads:[~2023-11-28 12:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-26 22:01 [PATCH v2 net] r8169: prevent potential deadlock in rtl8169_close Heiner Kallweit
2023-11-28 12:10 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.