Skip to content

Commit 91d3d14

Browse files
hkallweitPaolo Abeni
authored andcommitted
r8169: prevent potential deadlock in rtl8169_close
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: abe5fc4 ("r8169: use RTNL to protect critical sections") Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Link: https://lore.kernel.org/r/12395867-1d17-4cac-aa7d-c691938fcddf@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 59d395e commit 91d3d14

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/net/ethernet/realtek/r8169_main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4694,7 +4694,7 @@ static int rtl8169_close(struct net_device *dev)
46944694
rtl8169_down(tp);
46954695
rtl8169_rx_clear(tp);
46964696

4697-
cancel_work_sync(&tp->wk.work);
4697+
cancel_work(&tp->wk.work);
46984698

46994699
free_irq(tp->irq, tp);
47004700

@@ -4928,6 +4928,8 @@ static void rtl_remove_one(struct pci_dev *pdev)
49284928
if (pci_dev_run_wake(pdev))
49294929
pm_runtime_get_noresume(&pdev->dev);
49304930

4931+
cancel_work_sync(&tp->wk.work);
4932+
49314933
unregister_netdev(tp->dev);
49324934

49334935
if (tp->dash_type != RTL_DASH_NONE)

0 commit comments

Comments
 (0)