From: VMware, Inc <> Date: Thu, 18 Nov 2010 22:16:50 +0000 (-0800) Subject: Move kmap outside of critical section in VMCIHost_GetUserMemory X-Git-Tag: 2010.11.17-327185~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=390bb8ab054fc0a6a45056bab1ca98f2f2252ba3;p=thirdparty%2Fopen-vm-tools.git Move kmap outside of critical section in VMCIHost_GetUserMemory While calling get_user_pages, we grab current->mm->mmap_sem. However, we do not need to hold on to it while doing kmap, and since kmap may sleep, it seems like a genuinely bad idea. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/modules/linux/vmci/vmciKernelIf.c b/open-vm-tools/modules/linux/vmci/vmciKernelIf.c index 566d441b3..d753b05d9 100644 --- a/open-vm-tools/modules/linux/vmci/vmciKernelIf.c +++ b/open-vm-tools/modules/linux/vmci/vmciKernelIf.c @@ -1619,6 +1619,9 @@ VMCIHost_GetUserMemory(PageStoreAttachInfo *attach, // IN/OUT err = VMCI_ERROR_NO_MEM; } +out: + up_write(¤t->mm->mmap_sem); + if (err == VMCI_SUCCESS) { produceQ->qHeader = kmap(attach->producePages[0]); produceQ->kernelIf->page = &attach->producePages[1]; @@ -1626,9 +1629,6 @@ VMCIHost_GetUserMemory(PageStoreAttachInfo *attach, // IN/OUT consumeQ->kernelIf->page = &attach->consumePages[1]; } -out: - up_write(¤t->mm->mmap_sem); - errorDealloc: if (err < VMCI_SUCCESS) { if (attach->producePages != NULL) {