sync with trunk r47346
[reactos.git] / ntoskrnl / io / iomgr / driver.c
index 1ab5445..7dcb035 100644 (file)
@@ -1171,17 +1171,18 @@ IopUnloadDriver(PUNICODE_STRING DriverServiceName, BOOLEAN UnloadPnpDrivers)
                                     0,
                                     (PVOID*)&DriverObject);
 
-   /*
-    * Free the buffer for driver object name
-    */
-   ExFreePool(ObjectName.Buffer);
-
    if (!NT_SUCCESS(Status))
    {
       DPRINT1("Can't locate driver object for %wZ\n", &ObjectName);
+      ExFreePool(ObjectName.Buffer);
       return Status;
    }
 
+   /*
+    * Free the buffer for driver object name
+    */
+   ExFreePool(ObjectName.Buffer);
+
    /* Check that driver is not already unloading */
    if (DriverObject->Flags & DRVO_UNLOAD_INVOKED)
    {
@@ -1555,11 +1556,14 @@ try_again:
          * Doing so is illegal; drivers shouldn't touch entry points they
          * do not implement.
          */
-        ASSERT(DriverObject->MajorFunction[i] != NULL);
 
         /* Check if it did so anyway */
-               if (!DriverObject->MajorFunction[i])
+        if (!DriverObject->MajorFunction[i])
         {
+            /* Print a warning in the debug log */
+            DPRINT1("Driver <%wZ> set DriverObject->MajorFunction[%d] to NULL!\n",
+                    &DriverObject->DriverName, i);
+
             /* Fix it up */
             DriverObject->MajorFunction[i] = IopInvalidDeviceRequest;
         }