Commit 3f735131 authored by Haiyang Zhang's avatar Haiyang Zhang Committed by David S. Miller

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: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5e82b4b2
...@@ -986,12 +986,6 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc) ...@@ -986,12 +986,6 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
nvscdev = hv_get_drvdata(new_sc->primary_channel->device_obj); 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) if (chn_index >= nvscdev->num_chn)
return; return;
...@@ -1004,6 +998,12 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc) ...@@ -1004,6 +998,12 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
if (ret == 0) if (ret == 0)
nvscdev->chn_table[chn_index] = new_sc; 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, int rndis_filter_device_add(struct hv_device *dev,
......
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