summaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorJorgen Hansen <jhansen@vmware.com>2016-10-06 07:43:08 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-10-28 08:26:21 -0400
commiteb94cd68abd9b7c92bf70ddc452d65f1a84c46e2 (patch)
tree137aba204ea5ee978a4f8a908912192a834d0fe8 /drivers/misc
parenta7a7aeefbca2982586ba2c9fd7739b96416a6d1d (diff)
VMCI: Doorbell create and destroy fixes
This change consists of two changes: 1) If vmci_doorbell_create is called when neither guest nor host personality as been initialized, vmci_get_context_id will return VMCI_INVALID_ID. In that case, we should fail the create call. 2) In doorbell destroy, we assume that vmci_guest_code_active() has the same return value on create and destroy. That may not be the case, so we may end up with the wrong refcount. Instead, destroy should check explicitly whether the doorbell is in the index table as an indicator of whether the guest code was active at create time. Reviewed-by: Adit Ranadive <aditr@vmware.com> Signed-off-by: Jorgen Hansen <jhansen@vmware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/vmw_vmci/vmci_doorbell.c8
-rw-r--r--drivers/misc/vmw_vmci/vmci_driver.c2
2 files changed, 8 insertions, 2 deletions
diff --git a/drivers/misc/vmw_vmci/vmci_doorbell.c b/drivers/misc/vmw_vmci/vmci_doorbell.c
index a8cee33ae8d2..b3fa738ae005 100644
--- a/drivers/misc/vmw_vmci/vmci_doorbell.c
+++ b/drivers/misc/vmw_vmci/vmci_doorbell.c
@@ -431,6 +431,12 @@ int vmci_doorbell_create(struct vmci_handle *handle,
431 if (vmci_handle_is_invalid(*handle)) { 431 if (vmci_handle_is_invalid(*handle)) {
432 u32 context_id = vmci_get_context_id(); 432 u32 context_id = vmci_get_context_id();
433 433
434 if (context_id == VMCI_INVALID_ID) {
435 pr_warn("Failed to get context ID\n");
436 result = VMCI_ERROR_NO_RESOURCES;
437 goto free_mem;
438 }
439
434 /* Let resource code allocate a free ID for us */ 440 /* Let resource code allocate a free ID for us */
435 new_handle = vmci_make_handle(context_id, VMCI_INVALID_ID); 441 new_handle = vmci_make_handle(context_id, VMCI_INVALID_ID);
436 } else { 442 } else {
@@ -525,7 +531,7 @@ int vmci_doorbell_destroy(struct vmci_handle handle)
525 531
526 entry = container_of(resource, struct dbell_entry, resource); 532 entry = container_of(resource, struct dbell_entry, resource);
527 533
528 if (vmci_guest_code_active()) { 534 if (!hlist_unhashed(&entry->node)) {
529 int result; 535 int result;
530 536
531 dbell_index_table_remove(entry); 537 dbell_index_table_remove(entry);
diff --git a/drivers/misc/vmw_vmci/vmci_driver.c b/drivers/misc/vmw_vmci/vmci_driver.c
index 896be150e28f..d7eaf1eb11e7 100644
--- a/drivers/misc/vmw_vmci/vmci_driver.c
+++ b/drivers/misc/vmw_vmci/vmci_driver.c
@@ -113,5 +113,5 @@ module_exit(vmci_drv_exit);
113 113
114MODULE_AUTHOR("VMware, Inc."); 114MODULE_AUTHOR("VMware, Inc.");
115MODULE_DESCRIPTION("VMware Virtual Machine Communication Interface."); 115MODULE_DESCRIPTION("VMware Virtual Machine Communication Interface.");
116MODULE_VERSION("1.1.4.0-k"); 116MODULE_VERSION("1.1.5.0-k");
117MODULE_LICENSE("GPL v2"); 117MODULE_LICENSE("GPL v2");