https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f0c7f862d4da673ea3e4120918924af7a03ed0df

commit f0c7f862d4da673ea3e4120918924af7a03ed0df
Author:     Pierre Schweitzer <[email protected]>
AuthorDate: Thu Feb 8 14:15:02 2018 +0100
Commit:     Pierre Schweitzer <[email protected]>
CommitDate: Thu Feb 8 14:15:02 2018 +0100

    [NTOSKRNL] Fix a ****ing bug where private cache map was deleted in 
CcUninitializeCacheMap()
    before the call to CcRosReleaseFileCache() which expects to have it to 
properly clean the file.
    So, move deletion code to CcRosReleaseFileCache() so that he's the only one 
to handle private map.
    Should hopefully fix all the recent buildbots issues (and the universe 
perhaps, who knows?)
---
 ntoskrnl/cc/fs.c   | 19 -------------------
 ntoskrnl/cc/view.c | 14 ++++++++++++++
 2 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/ntoskrnl/cc/fs.c b/ntoskrnl/cc/fs.c
index 7be40ae82b..38c9ae527c 100644
--- a/ntoskrnl/cc/fs.c
+++ b/ntoskrnl/cc/fs.c
@@ -346,25 +346,6 @@ CcUninitializeCacheMap (
                             FALSE);
     }
 
-    /* Closing the handle, so kill the private cache map */
-    if (FileObject->SectionObjectPointer->SharedCacheMap != NULL &&
-        FileObject->PrivateCacheMap != NULL)
-    {
-        PPRIVATE_CACHE_MAP PrivateMap;
-
-        PrivateMap = FileObject->PrivateCacheMap;
-        SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
-
-        /* Remove it from the file */
-        KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &OldIrql);
-        RemoveEntryList(&PrivateMap->PrivateLinks);
-        KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, OldIrql);
-
-        /* And free it */
-        FileObject->PrivateCacheMap = NULL;
-        ExFreePoolWithTag(PrivateMap, TAG_PRIVATE_CACHE_MAP);
-    }
-
     Status = CcRosReleaseFileCache(FileObject);
     if (UninitializeCompleteEvent)
     {
diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c
index 18eaac50e8..4823d04268 100644
--- a/ntoskrnl/cc/view.c
+++ b/ntoskrnl/cc/view.c
@@ -1180,7 +1180,21 @@ CcRosReleaseFileCache (
         SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
         if (FileObject->PrivateCacheMap != NULL)
         {
+            KIRQL OldIrql;
+            PPRIVATE_CACHE_MAP PrivateMap;
+
+            /* Closing the handle, so kill the private cache map */
+            PrivateMap = FileObject->PrivateCacheMap;
+
+            /* Remove it from the file */
+            KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &OldIrql);
+            RemoveEntryList(&PrivateMap->PrivateLinks);
+            KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, OldIrql);
+
+            /* And free it */
             FileObject->PrivateCacheMap = NULL;
+            ExFreePoolWithTag(PrivateMap, TAG_PRIVATE_CACHE_MAP);
+
             if (SharedCacheMap->OpenCount > 0)
             {
                 SharedCacheMap->OpenCount--;

Reply via email to