[FASTFAT]
authorThomas Faber <thomas.faber@reactos.org>
Wed, 5 Nov 2014 23:23:52 +0000 (23:23 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Wed, 5 Nov 2014 23:23:52 +0000 (23:23 +0000)
- Fix incorrect referencing in VfatCreateFile. vfatGetFCBForFile expects a reference on ParentFcb (and may release it), and also returns a referenced parent FCB.
CORE-8756 #resolve

svn path=/trunk/; revision=65276

reactos/drivers/filesystems/fastfat/create.c
reactos/drivers/filesystems/fastfat/direntry.c
reactos/drivers/filesystems/fastfat/dirwr.c

index 32b372e..c55d9ee 100644 (file)
@@ -565,11 +565,14 @@ VfatCreateFile(
         LONG idx, FileNameLen;
 
         ParentFcb = (FileObject->RelatedFileObject != NULL) ? FileObject->RelatedFileObject->FsContext : NULL;
+        if (ParentFcb)
+        {
+            vfatGrabFCB(DeviceExt, ParentFcb);
+        }
         Status = vfatGetFCBForFile(DeviceExt, &ParentFcb, &TargetFcb, &PathNameU);
 
-        if (Status == STATUS_SUCCESS)
+        if (NT_SUCCESS(Status))
         {
-            vfatGrabFCB(DeviceExt, ParentFcb);
             vfatReleaseFCB(DeviceExt, TargetFcb);
             Irp->IoStatus.Information = FILE_EXISTS;
         }
@@ -623,6 +626,7 @@ VfatCreateFile(
         if (NT_SUCCESS(Status))
         {
             pFcb = FileObject->FsContext;
+            ASSERT(pFcb == ParentFcb);
 
             if (pFcb->OpenHandleCount == 0)
             {
@@ -640,7 +644,6 @@ VfatCreateFile(
                                             FALSE);
                 if (!NT_SUCCESS(Status))
                 {
-                    vfatReleaseFCB(DeviceExt, ParentFcb);
                     VfatCloseFile(DeviceExt, FileObject);
                     return Status;
                 }
index f3dc5b9..336f014 100644 (file)
@@ -201,12 +201,6 @@ FATGetNextDirEntry(
             CcUnpinData(*pContext);
         }
 
-        if (!pDirFcb->FileObject)
-        {
-            DPRINT1("Buggy FCB (cleaned up)! %S (%d / %u)\n", pDirFcb->PathNameBuffer, pDirFcb->RefCount, pDirFcb->OpenHandleCount);
-            return STATUS_NO_MORE_ENTRIES;
-        }
-
         if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
             !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
         {
index e9622a8..21b0e69 100644 (file)
@@ -167,11 +167,6 @@ vfatFindDirSpace(
             {
                 CcUnpinData(Context);
             }
-            if (!pDirFcb->FileObject)
-            {
-                DPRINT1("Buggy FCB (cleaned up)! %S (%d / %u)\n", pDirFcb->PathNameBuffer, pDirFcb->RefCount, pDirFcb->OpenHandleCount);
-                return FALSE;
-            }
             if (!CcPinRead(pDirFcb->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster,
                       TRUE, &Context, (PVOID*)&pFatEntry))
             {