diff --git a/drivers/filesystems/fastfat/dirwr.c b/drivers/filesystems/fastfat/dirwr.c index dc073f92369..4237d019095 100644 --- a/drivers/filesystems/fastfat/dirwr.c +++ b/drivers/filesystems/fastfat/dirwr.c @@ -29,6 +29,7 @@ vfatFCBInitializeCacheFromVolume( PVFATCCB newCCB; NTSTATUS status; BOOLEAN Acquired; + NTSTATUS Status; /* Don't re-initialize if already done */ if (BooleanFlagOn(fcb->Flags, FCB_CACHE_INITIALIZED)) @@ -58,8 +59,9 @@ vfatFCBInitializeCacheFromVolume( newCCB = ExAllocateFromNPagedLookasideList(&VfatGlobalData->CcbLookasideList); if (newCCB == NULL) { + Status = STATUS_INSUFFICIENT_RESOURCES; ObDereferenceObject(fileObject); - return STATUS_INSUFFICIENT_RESOURCES; + goto Quit; } RtlZeroMemory(newCCB, sizeof (VFATCCB)); @@ -83,19 +85,25 @@ vfatFCBInitializeCacheFromVolume( fcb->FileObject = NULL; ExFreeToNPagedLookasideList(&VfatGlobalData->CcbLookasideList, newCCB); ObDereferenceObject(fileObject); + if (Acquired) + { + ExReleaseResourceLite(&vcb->DirResource); + } return status; } _SEH2_END; vfatGrabFCB(vcb, fcb); SetFlag(fcb->Flags, FCB_CACHE_INITIALIZED); + Status = STATUS_SUCCESS; +Quit: if (Acquired) { ExReleaseResourceLite(&vcb->DirResource); } - return STATUS_SUCCESS; + return Status; } /* @@ -682,6 +690,7 @@ FATAddEntry( } /* No need to init cache here, vfatFindDirSpace() will have done it for us */ + ASSERT(BooleanFlagOn(ParentFcb->Flags, FCB_CACHE_INITIALIZED)); i = DeviceExt->FatInfo.BytesPerCluster / sizeof(FAT_DIR_ENTRY); FileOffset.u.HighPart = 0; @@ -768,6 +777,7 @@ FATAddEntry( Status = vfatFCBInitializeCacheFromVolume(DeviceExt, (*Fcb)); if (!NT_SUCCESS(Status)) { + ExFreePoolWithTag(Buffer, TAG_VFAT); return Status; } @@ -898,6 +908,7 @@ FATXAddEntry( } /* No need to init cache here, vfatFindDirSpace() will have done it for us */ + ASSERT(BooleanFlagOn(ParentFcb->Flags, FCB_CACHE_INITIALIZED)); /* add entry into parent directory */ FileOffset.u.HighPart = 0;