From a837694518ded3114e59ab39028b1f92707664c1 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Fri, 18 May 2018 14:51:24 +0200 Subject: [PATCH] [FASTFAT] Uninit directory cache on last handle close. CORE-14629 CORE-14557 --- drivers/filesystems/fastfat/close.c | 13 +++++++++++++ drivers/filesystems/fastfat/dirwr.c | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/filesystems/fastfat/close.c b/drivers/filesystems/fastfat/close.c index 992ccac4c2c..bb5cfaae786 100644 --- a/drivers/filesystems/fastfat/close.c +++ b/drivers/filesystems/fastfat/close.c @@ -48,6 +48,19 @@ VfatCloseFile( } else { + if (pFcb->OpenHandleCount == 0 && BooleanFlagOn(pFcb->Flags, FCB_CACHE_INITIALIZED)) + { + PFILE_OBJECT tmpFileObject; + tmpFileObject = pFcb->FileObject; + if (tmpFileObject != NULL) + { + pFcb->FileObject = NULL; + CcUninitializeCacheMap(tmpFileObject, NULL, NULL); + ClearFlag(pFcb->Flags, FCB_CACHE_INITIALIZED); + ObDereferenceObject(tmpFileObject); + } + } + #ifdef KDBG pFcb->Flags |= FCB_CLOSED; #endif diff --git a/drivers/filesystems/fastfat/dirwr.c b/drivers/filesystems/fastfat/dirwr.c index e2026b8cd9c..dc073f92369 100644 --- a/drivers/filesystems/fastfat/dirwr.c +++ b/drivers/filesystems/fastfat/dirwr.c @@ -37,6 +37,7 @@ vfatFCBInitializeCacheFromVolume( } ASSERT(vfatFCBIsDirectory(fcb)); + ASSERT(fcb->FileObject == NULL); Acquired = FALSE; if (!ExIsResourceAcquiredExclusive(&vcb->DirResource))