Commit abe5fc42 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by David S. Miller

r8169: use RTNL to protect critical sections

Most relevant ops (open, close, ethtool ops) are protected with RTNL
lock by net core. Make sure that such ops can't be interrupted by
e.g. (runtime-)suspending by taking the RTNL lock in suspend ops
and the PCI error handler.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 567ca57f
...@@ -4524,6 +4524,7 @@ static void rtl_task(struct work_struct *work) ...@@ -4524,6 +4524,7 @@ static void rtl_task(struct work_struct *work)
struct rtl8169_private *tp = struct rtl8169_private *tp =
container_of(work, struct rtl8169_private, wk.work); container_of(work, struct rtl8169_private, wk.work);
rtnl_lock();
rtl_lock_work(tp); rtl_lock_work(tp);
if (!netif_running(tp->dev) || if (!netif_running(tp->dev) ||
...@@ -4536,6 +4537,7 @@ static void rtl_task(struct work_struct *work) ...@@ -4536,6 +4537,7 @@ static void rtl_task(struct work_struct *work)
} }
out_unlock: out_unlock:
rtl_unlock_work(tp); rtl_unlock_work(tp);
rtnl_unlock();
} }
static int rtl8169_poll(struct napi_struct *napi, int budget) static int rtl8169_poll(struct napi_struct *napi, int budget)
...@@ -4788,7 +4790,9 @@ static int __maybe_unused rtl8169_suspend(struct device *device) ...@@ -4788,7 +4790,9 @@ static int __maybe_unused rtl8169_suspend(struct device *device)
{ {
struct rtl8169_private *tp = dev_get_drvdata(device); struct rtl8169_private *tp = dev_get_drvdata(device);
rtnl_lock();
rtl8169_net_suspend(tp); rtl8169_net_suspend(tp);
rtnl_unlock();
return 0; return 0;
} }
...@@ -4816,11 +4820,13 @@ static int rtl8169_runtime_suspend(struct device *device) ...@@ -4816,11 +4820,13 @@ static int rtl8169_runtime_suspend(struct device *device)
return 0; return 0;
} }
rtnl_lock();
rtl_lock_work(tp); rtl_lock_work(tp);
__rtl8169_set_wol(tp, WAKE_PHY); __rtl8169_set_wol(tp, WAKE_PHY);
rtl_unlock_work(tp); rtl_unlock_work(tp);
rtl8169_net_suspend(tp); rtl8169_net_suspend(tp);
rtnl_unlock();
return 0; return 0;
} }
...@@ -4882,7 +4888,9 @@ static void rtl_shutdown(struct pci_dev *pdev) ...@@ -4882,7 +4888,9 @@ static void rtl_shutdown(struct pci_dev *pdev)
{ {
struct rtl8169_private *tp = pci_get_drvdata(pdev); struct rtl8169_private *tp = pci_get_drvdata(pdev);
rtnl_lock();
rtl8169_net_suspend(tp); rtl8169_net_suspend(tp);
rtnl_unlock();
/* Restore original MAC address */ /* Restore original MAC address */
rtl_rar_set(tp, tp->dev->perm_addr); rtl_rar_set(tp, tp->dev->perm_addr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment