* Sync up to trunk head (r64921).
[reactos.git] / ntoskrnl / io / iomgr / error.c
index 0fa5f56..91c1621 100644 (file)
@@ -310,11 +310,9 @@ IopLogWorker(IN PVOID Parameter)
             /* We do, query its name */
             Status = ObQueryNameString(LogEntry->DeviceObject,
                                        ObjectNameInfo,
-                                       sizeof(OBJECT_NAME_INFORMATION) +
-                                       100 -
-                                       DriverNameLength,
+                                       sizeof(Buffer),
                                        &ReturnedLength);
-            if ((!NT_SUCCESS(Status)) || !(ObjectNameInfo->Name.Length))
+            if (!NT_SUCCESS(Status) || (ObjectNameInfo->Name.Length == 0))
             {
                 /* Setup an empty name */
                 ObjectNameInfo->Name.Length = 0;
@@ -367,7 +365,12 @@ IopLogWorker(IN PVOID Parameter)
         DeviceNameLength += sizeof(WCHAR);
 
         /* Free the buffer if we had one */
-        if (PoolObjectNameInfo) ExFreePool(PoolObjectNameInfo);
+        if (PoolObjectNameInfo)
+        {
+            ExFreePool(PoolObjectNameInfo);
+            PoolObjectNameInfo = NULL;
+            ObjectNameInfo = (POBJECT_NAME_INFORMATION)&Buffer;
+        }
 
         /* Go to the next string buffer position */
         ErrorMessage->EntryData.NumberOfStrings++;
@@ -428,7 +431,7 @@ IopLogWorker(IN PVOID Parameter)
             break;
         }
 
-        /* Derefernece the device object */
+        /* Dereference the device object */
         if (LogEntry->DeviceObject) ObDereferenceObject(LogEntry->DeviceObject);
         if (DriverObject) ObDereferenceObject(LogEntry->DriverObject);
 
@@ -486,8 +489,8 @@ IoAllocateErrorLogEntry(IN PVOID IoObject,
 {
     PERROR_LOG_ENTRY LogEntry;
     ULONG LogEntrySize;
-    PDRIVER_OBJECT DriverObject;
     PDEVICE_OBJECT DeviceObject;
+    PDRIVER_OBJECT DriverObject;
 
     /* Make sure we have an object */
     if (!IoObject) return NULL;
@@ -495,13 +498,6 @@ IoAllocateErrorLogEntry(IN PVOID IoObject,
     /* Check if we're past our buffer */
     if (IopTotalLogSize > PAGE_SIZE) return NULL;
 
-    /* Calculate the total size and allocate it */
-    LogEntrySize = sizeof(ERROR_LOG_ENTRY) + EntrySize;
-    LogEntry = ExAllocatePoolWithTag(NonPagedPool,
-                                     LogEntrySize,
-                                     TAG_ERROR_LOG);
-    if (!LogEntry) return NULL;
-
     /* Check if this is a device object or driver object */
     if (((PDEVICE_OBJECT)IoObject)->Type == IO_TYPE_DEVICE)
     {
@@ -511,9 +507,9 @@ IoAllocateErrorLogEntry(IN PVOID IoObject,
     }
     else if (((PDEVICE_OBJECT)IoObject)->Type == IO_TYPE_DRIVER)
     {
-        /* It's a driver, so we don' thave a device */
+        /* It's a driver, so we don'have a device */
         DeviceObject = NULL;
-        DriverObject = IoObject;
+        DriverObject = (PDRIVER_OBJECT)IoObject;
     }
     else
     {
@@ -521,6 +517,13 @@ IoAllocateErrorLogEntry(IN PVOID IoObject,
         return NULL;
     }
 
+    /* Calculate the total size and allocate it */
+    LogEntrySize = sizeof(ERROR_LOG_ENTRY) + EntrySize;
+    LogEntry = ExAllocatePoolWithTag(NonPagedPool,
+                                     LogEntrySize,
+                                     TAG_ERROR_LOG);
+    if (!LogEntry) return NULL;
+
     /* Reference the Objects */
     if (DeviceObject) ObReferenceObject(DeviceObject);
     if (DriverObject) ObReferenceObject(DriverObject);