From: Pierre Schweitzer Date: Sat, 29 Sep 2018 14:21:44 +0000 (+0200) Subject: [NTOSKRNL] Don't lock file object on close if we're not called by Ob X-Git-Tag: 0.4.12-dev~703 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=cf25432eedcd6c071912c54e55f219104faf83f1;ds=sidebyside [NTOSKRNL] Don't lock file object on close if we're not called by Ob IopCloseFile can be called by IopDeleteFile. In that situation, it doesn't set any process as first parameter. Furthermore, we are in a situation where it's not required to lock the file object (see the assert before the call). --- diff --git a/ntoskrnl/io/iomgr/file.c b/ntoskrnl/io/iomgr/file.c index e7633a331f9..c10729080d0 100644 --- a/ntoskrnl/io/iomgr/file.c +++ b/ntoskrnl/io/iomgr/file.c @@ -2033,7 +2033,11 @@ IopCloseFile(IN PEPROCESS Process OPTIONAL, FileObject->Flags |= FO_HANDLE_CREATED; /* Check if this is a sync FO and lock it */ - if (FileObject->Flags & FO_SYNCHRONOUS_IO) IopLockFileObject(FileObject); + if (Process != NULL && + BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO)) + { + IopLockFileObject(FileObject); + } /* Clear and set up Events */ KeClearEvent(&FileObject->Event); @@ -2078,7 +2082,11 @@ IopCloseFile(IN PEPROCESS Process OPTIONAL, IoFreeIrp(Irp); /* Release the lock if we were holding it */ - if (FileObject->Flags & FO_SYNCHRONOUS_IO) IopUnlockFileObject(FileObject); + if (Process != NULL && + BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO)) + { + IopUnlockFileObject(FileObject); + } } NTSTATUS