[NTOS] Remove some hacks that are not needed anymore, since a real registry hive...
[reactos.git] / ntoskrnl / config / i386 / cmhardwr.c
index fe314ab..b98c269 100644 (file)
@@ -382,7 +382,8 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
                                NULL,
                                NULL);
     Status = NtOpenKey(&SystemHandle, KEY_READ | KEY_WRITE, &ObjectAttributes);
-    if (!NT_SUCCESS(Status)) return Status;
+    if (!NT_SUCCESS(Status))
+        return Status;
 
     /* Create the BIOS Information key */
     RtlInitUnicodeString(&KeyName,
@@ -400,13 +401,11 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
                          NULL,
                          REG_OPTION_NON_VOLATILE,
                          &Disposition);
-    if (ExpInTextModeSetup)
+    if (!NT_SUCCESS(Status))
     {
-        if (!NT_SUCCESS(Status))
-            BiosHandle = NULL;
-    }
-    else if (!NT_SUCCESS(Status))
+        NtClose(SystemHandle);
         return Status;
+    }
 
     /* Create the CPU Key, and check if it already existed */
     RtlInitUnicodeString(&KeyName, L"CentralProcessor");
@@ -431,7 +430,11 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
         CmpConfigurationData = ExAllocatePoolWithTag(PagedPool,
                                                      CmpConfigurationAreaSize,
                                                      TAG_CM);
-        if (!CmpConfigurationData) return STATUS_INSUFFICIENT_RESOURCES;
+        if (!CmpConfigurationData)
+        {
+            // FIXME: Cleanup stuff!!
+            return STATUS_INSUFFICIENT_RESOURCES;
+        }
 
         /* Loop all CPUs */
         for (i = 0; i < KeNumberProcessors; i++)
@@ -440,7 +443,7 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
             Prcb = KiProcessorBlock[i];
 
             /* Setup the Configuration Entry for the Processor */
-            RtlZeroMemory(&ConfigData, sizeof (ConfigData));
+            RtlZeroMemory(&ConfigData, sizeof(ConfigData));
             ConfigData.ComponentEntry.Class = ProcessorClass;
             ConfigData.ComponentEntry.Type = CentralProcessor;
             ConfigData.ComponentEntry.Key = i;
@@ -477,7 +480,12 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
                                                InterfaceTypeUndefined,
                                                0xFFFFFFFF,
                                                IndexTable);
-            if (!NT_SUCCESS(Status)) return(Status);
+            if (!NT_SUCCESS(Status))
+            {
+                NtClose(BiosHandle);
+                NtClose(SystemHandle);
+                return Status;
+            }
 
             /* Check if we have an FPU */
             if (KeI386NpxPresent)
@@ -505,8 +513,10 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
                                                    IndexTable);
                 if (!NT_SUCCESS(Status))
                 {
-                    /* Failed, close the CPU handle and return */
+                    /* We failed, close all the opened handles and return */
                     NtClose(KeyHandle);
+                    NtClose(BiosHandle);
+                    NtClose(SystemHandle);
                     return Status;
                 }
 
@@ -672,7 +682,15 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
     Status = ZwOpenSection(&SectionHandle,
                            SECTION_ALL_ACCESS,
                            &ObjectAttributes);
-    if (!NT_SUCCESS(Status)) goto Quickie;
+    if (!NT_SUCCESS(Status))
+    {
+        /* We failed, close all the opened handles and return */
+        // NtClose(KeyHandle);
+        NtClose(BiosHandle);
+        NtClose(SystemHandle);
+        /* 'Quickie' closes KeyHandle */
+        goto Quickie;
+    }
 
     /* Map the first 1KB of memory to get the IVT */
     ViewSize = PAGE_SIZE;
@@ -939,7 +957,7 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
     if (BiosVersion) ExFreePoolWithTag(BiosVersion, TAG_CM);
 
 Quickie:
-    /* Close the procesor handle */
+    /* Close the processor handle */
     NtClose(KeyHandle);
     return STATUS_SUCCESS;
 }