summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorHaiyang Zhang <haiyangz@microsoft.com>2016-03-24 00:54:48 +0300
committerDavid S. Miller <davem@davemloft.net>2016-03-24 04:51:08 +0300
commit3f735131d9c2523eb54a6c5099fa8c60a4292d48 (patch)
tree04a88fdbeb47170da18679d7d8bbf7c1876c57c2 /drivers
parent5e82b4b2a0015ed0a659b22ef2ee3409a3c39e54 (diff)
downloadlinux-3f735131d9c2523eb54a6c5099fa8c60a4292d48.tar.xz
hv_netvsc: Fix the order of num_sc_offered decrement
Reorder the code in netvsc_sc_open(), so num_sc_offered is only decremented after vmbus_open() is called. This avoid pontential race of removing device before all channels are setup. Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com> Reviewed-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/hyperv/rndis_filter.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index d5a54da5d9c8..c4e1e0408433 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -986,12 +986,6 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
nvscdev = hv_get_drvdata(new_sc->primary_channel->device_obj);
- spin_lock_irqsave(&nvscdev->sc_lock, flags);
- nvscdev->num_sc_offered--;
- spin_unlock_irqrestore(&nvscdev->sc_lock, flags);
- if (nvscdev->num_sc_offered == 0)
- complete(&nvscdev->channel_init_wait);
-
if (chn_index >= nvscdev->num_chn)
return;
@@ -1004,6 +998,12 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
if (ret == 0)
nvscdev->chn_table[chn_index] = new_sc;
+
+ spin_lock_irqsave(&nvscdev->sc_lock, flags);
+ nvscdev->num_sc_offered--;
+ spin_unlock_irqrestore(&nvscdev->sc_lock, flags);
+ if (nvscdev->num_sc_offered == 0)
+ complete(&nvscdev->channel_init_wait);
}
int rndis_filter_device_add(struct hv_device *dev,