[WIN32K]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Mon, 21 Apr 2014 17:09:27 +0000 (17:09 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Mon, 21 Apr 2014 17:09:27 +0000 (17:09 +0000)
Do not ignore failure when calling DrvEnablePDEV and properly handle a failure in PDEVOBJ_bEnablePDEV instead of ASSERTing. Properly cleanup the PDEV after failure, check if the PDEV was enabled before calling DrvDisablePDEV. Fixes some crashes with VBox driver.

svn path=/trunk/; revision=62855

reactos/win32ss/gdi/eng/pdevobj.c

index 8e5a4d0..a2feddc 100644 (file)
@@ -94,8 +94,12 @@ PDEVOBJ_vRelease(PPDEVOBJ ppdev)
             PALETTE_ShareUnlockPalette(ppdev->ppalSurf);
         }
 
-        /* Disable PDEV */
-        ppdev->pfn.DisablePDEV(ppdev->dhpdev);
+        /* Check if the PDEV was enabled */
+        if (ppdev->dhpdev != NULL)
+        {
+            /* Disable the PDEV */
+            ppdev->pfn.DisablePDEV(ppdev->dhpdev);
+        }
 
         /* Remove it from list */
         if( ppdev == gppdevList )
@@ -155,6 +159,11 @@ PDEVOBJ_bEnablePDEV(
                                   (HDEV)ppdev,
                                   ppdev->pGraphicsDevice->pwszDescription,
                                   ppdev->pGraphicsDevice->DeviceObject);
+    if (ppdev->dhpdev == NULL)
+    {
+        DPRINT1("Failed to enable PDEV\n");
+        return FALSE;
+    }
 
     /* Fix up some values */
     if (ppdev->gdiinfo.ulLogPixelsX == 0)
@@ -337,7 +346,8 @@ EngpCreatePDEV(
     if (!PDEVOBJ_bEnablePDEV(ppdev, pdm, NULL))
     {
         DPRINT1("Failed to enable PDEV!\n");
-        ASSERT(FALSE);
+        PDEVOBJ_vRelease(ppdev);
+        return NULL;
     }
 
     /* FIXME: this must be done in a better way */