https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5ccd45ea58f8d3338d969d...
commit 5ccd45ea58f8d3338d969d815cf5ee46c73b34c7 Author: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org AuthorDate: Fri Sep 24 00:41:32 2021 +0200 Commit: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org CommitDate: Sun Sep 26 03:02:57 2021 +0200
[NTOS:RAWFS] Delete the previously-created devices in case the IoCreateDevice() calls fail. --- ntoskrnl/io/iomgr/rawfs.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/ntoskrnl/io/iomgr/rawfs.c b/ntoskrnl/io/iomgr/rawfs.c index b903fe3a31d..c1dfe0c20c0 100644 --- a/ntoskrnl/io/iomgr/rawfs.c +++ b/ntoskrnl/io/iomgr/rawfs.c @@ -1193,8 +1193,10 @@ NTAPI RawFsDriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath) { - UNICODE_STRING DeviceName; NTSTATUS Status; + UNICODE_STRING DeviceName; + + UNREFERENCED_PARAMETER(RegistryPath);
/* Create the raw disk device */ RtlInitUnicodeString(&DeviceName, L"\Device\RawDisk"); @@ -1205,7 +1207,10 @@ RawFsDriverEntry(IN PDRIVER_OBJECT DriverObject, 0, FALSE, &RawDiskDeviceObject); - if (!NT_SUCCESS(Status)) return Status; + if (!NT_SUCCESS(Status)) + { + return Status; + }
/* Create the raw CDROM device */ RtlInitUnicodeString(&DeviceName, L"\Device\RawCdRom"); @@ -1216,7 +1221,11 @@ RawFsDriverEntry(IN PDRIVER_OBJECT DriverObject, 0, FALSE, &RawCdromDeviceObject); - if (!NT_SUCCESS(Status)) return Status; + if (!NT_SUCCESS(Status)) + { + IoDeleteDevice(RawDiskDeviceObject); + return Status; + }
/* Create the raw tape device */ RtlInitUnicodeString(&DeviceName, L"\Device\RawTape"); @@ -1227,7 +1236,12 @@ RawFsDriverEntry(IN PDRIVER_OBJECT DriverObject, 0, FALSE, &RawTapeDeviceObject); - if (!NT_SUCCESS(Status)) return Status; + if (!NT_SUCCESS(Status)) + { + IoDeleteDevice(RawDiskDeviceObject); + IoDeleteDevice(RawCdromDeviceObject); + return Status; + }
/* Set Direct I/O for all devices */ RawDiskDeviceObject->Flags |= DO_DIRECT_IO;