diff options
author | Haiyang Zhang <haiyangz@microsoft.com> | 2012-08-03 05:32:18 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-08-03 19:51:11 -0400 |
commit | ae9e63bb2c0cf5437d9d13d822b27149336c6e0e (patch) | |
tree | 208ca440bec48067d84fbd86f04fa79bb55d00c3 /drivers/net | |
parent | 2207b60ffb6545040e2e2620fced13deba7643c2 (diff) |
hyperv: Move wait completion msg code into rndis_filter_halt_device()
We need to wait for send_completion msg before put_rndis_request() at
the end of rndis_filter_halt_device(). Otherwise, netvsc_send_completion()
may reference freed memory which is overwritten, and cause panic.
Reported-by: Long Li <longli@microsoft.com>
Reported-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/hyperv/netvsc.c | 7 | ||||
-rw-r--r-- | drivers/net/hyperv/rndis_filter.c | 11 |
2 files changed, 11 insertions, 7 deletions
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 6cee2917eb02..4a1a5f58fa73 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c | |||
@@ -383,13 +383,6 @@ int netvsc_device_remove(struct hv_device *device) | |||
383 | unsigned long flags; | 383 | unsigned long flags; |
384 | 384 | ||
385 | net_device = hv_get_drvdata(device); | 385 | net_device = hv_get_drvdata(device); |
386 | spin_lock_irqsave(&device->channel->inbound_lock, flags); | ||
387 | net_device->destroy = true; | ||
388 | spin_unlock_irqrestore(&device->channel->inbound_lock, flags); | ||
389 | |||
390 | /* Wait for all send completions */ | ||
391 | wait_event(net_device->wait_drain, | ||
392 | atomic_read(&net_device->num_outstanding_sends) == 0); | ||
393 | 386 | ||
394 | netvsc_disconnect_vsp(net_device); | 387 | netvsc_disconnect_vsp(net_device); |
395 | 388 | ||
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index e5d6146937fa..1e88a1095934 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c | |||
@@ -718,6 +718,9 @@ static void rndis_filter_halt_device(struct rndis_device *dev) | |||
718 | { | 718 | { |
719 | struct rndis_request *request; | 719 | struct rndis_request *request; |
720 | struct rndis_halt_request *halt; | 720 | struct rndis_halt_request *halt; |
721 | struct netvsc_device *nvdev = dev->net_dev; | ||
722 | struct hv_device *hdev = nvdev->dev; | ||
723 | ulong flags; | ||
721 | 724 | ||
722 | /* Attempt to do a rndis device halt */ | 725 | /* Attempt to do a rndis device halt */ |
723 | request = get_rndis_request(dev, RNDIS_MSG_HALT, | 726 | request = get_rndis_request(dev, RNDIS_MSG_HALT, |
@@ -735,6 +738,14 @@ static void rndis_filter_halt_device(struct rndis_device *dev) | |||
735 | dev->state = RNDIS_DEV_UNINITIALIZED; | 738 | dev->state = RNDIS_DEV_UNINITIALIZED; |
736 | 739 | ||
737 | cleanup: | 740 | cleanup: |
741 | spin_lock_irqsave(&hdev->channel->inbound_lock, flags); | ||
742 | nvdev->destroy = true; | ||
743 | spin_unlock_irqrestore(&hdev->channel->inbound_lock, flags); | ||
744 | |||
745 | /* Wait for all send completions */ | ||
746 | wait_event(nvdev->wait_drain, | ||
747 | atomic_read(&nvdev->num_outstanding_sends) == 0); | ||
748 | |||
738 | if (request) | 749 | if (request) |
739 | put_rndis_request(dev, request); | 750 | put_rndis_request(dev, request); |
740 | return; | 751 | return; |