r8169: prevent potential deadlock in rtl8169_close
[ Upstream commit 91d3d149978ba7b238198dd80e4b823756aa7cfa ]
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: abe5fc42f9
("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
8a909c1198
commit
a36e00e957
@@ -4769,7 +4769,7 @@ static int rtl8169_close(struct net_device *dev)
|
|||||||
rtl8169_down(tp);
|
rtl8169_down(tp);
|
||||||
rtl8169_rx_clear(tp);
|
rtl8169_rx_clear(tp);
|
||||||
|
|
||||||
cancel_work_sync(&tp->wk.work);
|
cancel_work(&tp->wk.work);
|
||||||
|
|
||||||
free_irq(pci_irq_vector(pdev, 0), tp);
|
free_irq(pci_irq_vector(pdev, 0), tp);
|
||||||
|
|
||||||
@@ -5035,6 +5035,8 @@ static void rtl_remove_one(struct pci_dev *pdev)
|
|||||||
if (pci_dev_run_wake(pdev))
|
if (pci_dev_run_wake(pdev))
|
||||||
pm_runtime_get_noresume(&pdev->dev);
|
pm_runtime_get_noresume(&pdev->dev);
|
||||||
|
|
||||||
|
cancel_work_sync(&tp->wk.work);
|
||||||
|
|
||||||
unregister_netdev(tp->dev);
|
unregister_netdev(tp->dev);
|
||||||
|
|
||||||
if (r8168_check_dash(tp))
|
if (r8168_check_dash(tp))
|
||||||
|
Reference in New Issue
Block a user