Skip to content

Commit eb94cd6

Browse files
Jorgen Hansengregkh
authored andcommitted
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 <[email protected]> Signed-off-by: Jorgen Hansen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a7a7aee commit eb94cd6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

drivers/misc/vmw_vmci/vmci_doorbell.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,12 @@ int vmci_doorbell_create(struct vmci_handle *handle,
431431
if (vmci_handle_is_invalid(*handle)) {
432432
u32 context_id = vmci_get_context_id();
433433

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+
434440
/* Let resource code allocate a free ID for us */
435441
new_handle = vmci_make_handle(context_id, VMCI_INVALID_ID);
436442
} else {
@@ -525,7 +531,7 @@ int vmci_doorbell_destroy(struct vmci_handle handle)
525531

526532
entry = container_of(resource, struct dbell_entry, resource);
527533

528-
if (vmci_guest_code_active()) {
534+
if (!hlist_unhashed(&entry->node)) {
529535
int result;
530536

531537
dbell_index_table_remove(entry);

drivers/misc/vmw_vmci/vmci_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,5 @@ module_exit(vmci_drv_exit);
113113

114114
MODULE_AUTHOR("VMware, Inc.");
115115
MODULE_DESCRIPTION("VMware Virtual Machine Communication Interface.");
116-
MODULE_VERSION("1.1.4.0-k");
116+
MODULE_VERSION("1.1.5.0-k");
117117
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)