aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hv/channel_mgmt.c
diff options
context:
space:
mode:
authorVitaly Kuznetsov <vkuznets@redhat.com>2014-11-04 07:40:11 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-11-07 13:21:44 -0500
commit04a258c162a85c0f4ae56be67634dc43c9a4fa9b (patch)
tree999f2bdac525ea05d75899169d97695021fd5a29 /drivers/hv/channel_mgmt.c
parent31d4ea1a093fcf668d5f95af44b8d41488bdb7ec (diff)
Drivers: hv: vmbus: Fix a race condition when unregistering a device
When build with Debug the following crash is sometimes observed: Call Trace: [<ffffffff812b9600>] string+0x40/0x100 [<ffffffff812bb038>] vsnprintf+0x218/0x5e0 [<ffffffff810baf7d>] ? trace_hardirqs_off+0xd/0x10 [<ffffffff812bb4c1>] vscnprintf+0x11/0x30 [<ffffffff8107a2f0>] vprintk+0xd0/0x5c0 [<ffffffffa0051ea0>] ? vmbus_process_rescind_offer+0x0/0x110 [hv_vmbus] [<ffffffff8155c71c>] printk+0x41/0x45 [<ffffffffa004ebac>] vmbus_device_unregister+0x2c/0x40 [hv_vmbus] [<ffffffffa0051ecb>] vmbus_process_rescind_offer+0x2b/0x110 [hv_vmbus] ... This happens due to the following race: between 'if (channel->device_obj)' check in vmbus_process_rescind_offer() and pr_debug() in vmbus_device_unregister() the device can disappear. Fix the issue by taking an additional reference to the device before proceeding to vmbus_device_unregister(). Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Cc: <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hv/channel_mgmt.c')
-rw-r--r--drivers/hv/channel_mgmt.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index a2d1a9612c86..d36ce6835fb7 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -216,9 +216,16 @@ static void vmbus_process_rescind_offer(struct work_struct *work)
216 unsigned long flags; 216 unsigned long flags;
217 struct vmbus_channel *primary_channel; 217 struct vmbus_channel *primary_channel;
218 struct vmbus_channel_relid_released msg; 218 struct vmbus_channel_relid_released msg;
219 struct device *dev;
220
221 if (channel->device_obj) {
222 dev = get_device(&channel->device_obj->device);
223 if (dev) {
224 vmbus_device_unregister(channel->device_obj);
225 put_device(dev);
226 }
227 }
219 228
220 if (channel->device_obj)
221 vmbus_device_unregister(channel->device_obj);
222 memset(&msg, 0, sizeof(struct vmbus_channel_relid_released)); 229 memset(&msg, 0, sizeof(struct vmbus_channel_relid_released));
223 msg.child_relid = channel->offermsg.child_relid; 230 msg.child_relid = channel->offermsg.child_relid;
224 msg.header.msgtype = CHANNELMSG_RELID_RELEASED; 231 msg.header.msgtype = CHANNELMSG_RELID_RELEASED;