Commit 6da7225f authored by Vitaly Kuznetsov's avatar Vitaly Kuznetsov Committed by David S. Miller

hv_netvsc: synchronize netvsc_change_mtu()/netvsc_set_channels() with netvsc_remove()

When netvsc device is removed during mtu change or channels setup we get
into troubles as both paths are trying to remove the device. Synchronize
them with start_remove flag and rtnl lock.
Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0a1275ca
...@@ -759,7 +759,7 @@ static int netvsc_set_channels(struct net_device *net, ...@@ -759,7 +759,7 @@ static int netvsc_set_channels(struct net_device *net,
int ret = 0; int ret = 0;
bool recovering = false; bool recovering = false;
if (!nvdev || nvdev->destroy) if (net_device_ctx->start_remove || !nvdev || nvdev->destroy)
return -ENODEV; return -ENODEV;
num_chn = nvdev->num_chn; num_chn = nvdev->num_chn;
...@@ -907,7 +907,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) ...@@ -907,7 +907,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
u32 num_chn; u32 num_chn;
int ret = 0; int ret = 0;
if (nvdev == NULL || nvdev->destroy) if (ndevctx->start_remove || !nvdev || nvdev->destroy)
return -ENODEV; return -ENODEV;
if (nvdev->nvsp_version >= NVSP_PROTOCOL_VERSION_2) if (nvdev->nvsp_version >= NVSP_PROTOCOL_VERSION_2)
...@@ -1445,7 +1445,12 @@ static int netvsc_remove(struct hv_device *dev) ...@@ -1445,7 +1445,12 @@ static int netvsc_remove(struct hv_device *dev)
ndev_ctx = netdev_priv(net); ndev_ctx = netdev_priv(net);
net_device = ndev_ctx->nvdev; net_device = ndev_ctx->nvdev;
/* Avoid racing with netvsc_change_mtu()/netvsc_set_channels()
* removing the device.
*/
rtnl_lock();
ndev_ctx->start_remove = true; ndev_ctx->start_remove = true;
rtnl_unlock();
cancel_delayed_work_sync(&ndev_ctx->dwork); cancel_delayed_work_sync(&ndev_ctx->dwork);
cancel_work_sync(&ndev_ctx->work); cancel_work_sync(&ndev_ctx->work);
......
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