diff options
author | Dexuan Cui <decui@microsoft.com> | 2017-10-18 05:08:40 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-10-20 08:56:25 -0400 |
commit | 9d35593b4f0b89ab0c194349c7d357b3b159e99a (patch) | |
tree | 3e951524cc33dddf4ff16acb4dc51ccdc76c18c7 | |
parent | 66b83a4cdd3b73effdc285d1d66763c69ffe2ee8 (diff) |
vmbus: hvsock: add proper sync for vmbus_hvsock_device_unregister()
Without the patch, vmbus_hvsock_device_unregister() can destroy the device
prematurely when close() is called, and can cause NULl dereferencing or
potential data loss (the last portion of the data stream may be dropped
prematurely).
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/hv/channel_mgmt.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index 018d2e0f8ec5..379b0df123be 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c | |||
@@ -937,7 +937,10 @@ void vmbus_hvsock_device_unregister(struct vmbus_channel *channel) | |||
937 | { | 937 | { |
938 | BUG_ON(!is_hvsock_channel(channel)); | 938 | BUG_ON(!is_hvsock_channel(channel)); |
939 | 939 | ||
940 | channel->rescind = true; | 940 | /* We always get a rescind msg when a connection is closed. */ |
941 | while (!READ_ONCE(channel->probe_done) || !READ_ONCE(channel->rescind)) | ||
942 | msleep(1); | ||
943 | |||
941 | vmbus_device_unregister(channel->device_obj); | 944 | vmbus_device_unregister(channel->device_obj); |
942 | } | 945 | } |
943 | EXPORT_SYMBOL_GPL(vmbus_hvsock_device_unregister); | 946 | EXPORT_SYMBOL_GPL(vmbus_hvsock_device_unregister); |