Author: pschweitzer
Date: Fri May 1 18:58:00 2015
New Revision: 67502
URL:
http://svn.reactos.org/svn/reactos?rev=67502&view=rev
Log:
[NTFS]
Why would you allocate NTFS global data structure twice to use it from only one location?
Fix that misbehavior.
Modified:
trunk/reactos/drivers/filesystems/ntfs/ntfs.c
Modified: trunk/reactos/drivers/filesystems/ntfs/ntfs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/ntfs/n…
==============================================================================
--- trunk/reactos/drivers/filesystems/ntfs/ntfs.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/ntfs/ntfs.c [iso-8859-1] Fri May 1 18:58:00 2015
@@ -51,18 +51,28 @@
{
UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(DEVICE_NAME);
NTSTATUS Status;
+ PDEVICE_OBJECT DeviceObject;
TRACE_(NTFS, "DriverEntry(%p, '%wZ')\n", DriverObject,
RegistryPath);
- /* Initialize global data */
- NtfsGlobalData = ExAllocatePoolWithTag(NonPagedPool, sizeof(NTFS_GLOBAL_DATA),
'GRDN');
- if (!NtfsGlobalData)
+ Status = IoCreateDevice(DriverObject,
+ sizeof(NTFS_GLOBAL_DATA),
+ &DeviceName,
+ FILE_DEVICE_DISK_FILE_SYSTEM,
+ 0,
+ FALSE,
+ &DeviceObject);
+ if (!NT_SUCCESS(Status))
{
- Status = STATUS_INSUFFICIENT_RESOURCES;
- goto ErrorEnd;
+ WARN_(NTFS, "IoCreateDevice failed with status: %lx\n", Status);
+ return Status;
}
+ /* Initialize global data */
+ NtfsGlobalData = DeviceObject->DeviceExtension;
RtlZeroMemory(NtfsGlobalData, sizeof(NTFS_GLOBAL_DATA));
+
+ NtfsGlobalData->DeviceObject = DeviceObject;
NtfsGlobalData->Identifier.Type = NTFS_TYPE_GLOBAL_DATA;
NtfsGlobalData->Identifier.Size = sizeof(NTFS_GLOBAL_DATA);
@@ -89,34 +99,11 @@
/* Driver can't be unloaded */
DriverObject->DriverUnload = NULL;
- Status = IoCreateDevice(DriverObject,
- sizeof(NTFS_GLOBAL_DATA),
- &DeviceName,
- FILE_DEVICE_DISK_FILE_SYSTEM,
- 0,
- FALSE,
- &NtfsGlobalData->DeviceObject);
- if (!NT_SUCCESS(Status))
- {
- WARN_(NTFS, "IoCreateDevice failed with status: %lx\n", Status);
- goto ErrorEnd;
- }
-
NtfsGlobalData->DeviceObject->Flags |= DO_DIRECT_IO;
/* Register file system */
IoRegisterFileSystem(NtfsGlobalData->DeviceObject);
ObReferenceObject(NtfsGlobalData->DeviceObject);
-
-ErrorEnd:
- if (!NT_SUCCESS(Status))
- {
- if (NtfsGlobalData)
- {
- ExDeleteResourceLite(&NtfsGlobalData->Resource);
- ExFreePoolWithTag(NtfsGlobalData, 'GRDN');
- }
- }
return Status;
}