Skip to content

Commit 9d35593

Browse files
dcuigregkh
authored andcommitted
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>
1 parent 66b83a4 commit 9d35593

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/hv/channel_mgmt.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,10 @@ void vmbus_hvsock_device_unregister(struct vmbus_channel *channel)
937937
{
938938
BUG_ON(!is_hvsock_channel(channel));
939939

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+
941944
vmbus_device_unregister(channel->device_obj);
942945
}
943946
EXPORT_SYMBOL_GPL(vmbus_hvsock_device_unregister);

0 commit comments

Comments
 (0)