]> xenbits.xensource.com Git - pvdrivers/win/xencons.git/commitdiff
Ensure D0 <-> D3 transitions occur only from the correct state
authorOwen Smith <owen.smith@citrix.com>
Fri, 2 Mar 2018 13:15:29 +0000 (13:15 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Fri, 2 Mar 2018 14:18:53 +0000 (14:18 +0000)
Attempting to set D0 when already at D0 will trigger an ASSERT
and overwrite several variables.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
src/xencons/pdo.c

index 66ab03333378ddb62c792c6122f9427b94fa30a5..3b483a54ee40b88296e1f61efe46d53a43082eae 100644 (file)
@@ -457,6 +457,9 @@ PdoD3ToD0(
 
     ASSERT3U(KeGetCurrentIrql(), == , PASSIVE_LEVEL);
 
+    if (__PdoGetDevicePowerState(Pdo) == PowerDeviceD0)
+        goto done;
+
     KeRaiseIrql(DISPATCH_LEVEL, &Irql);
 
     status = XENBUS_SUSPEND(Acquire, &Pdo->SuspendInterface);
@@ -482,6 +485,7 @@ PdoD3ToD0(
     if (!NT_SUCCESS(status))
         goto fail4;
 
+done:
 #pragma prefast(suppress:28123)
     (VOID) IoSetDeviceInterfaceState(&Pdo->Dx->Link, TRUE);
 
@@ -532,6 +536,9 @@ PdoD0ToD3(
 #pragma prefast(suppress:28123)
     (VOID) IoSetDeviceInterfaceState(&Pdo->Dx->Link, FALSE);
 
+    if (__PdoGetDevicePowerState(Pdo) == PowerDeviceD3)
+        goto done;
+
     XENCONS_CONSOLE_ABI(D0ToD3, &Pdo->Abi);
 
     KeRaiseIrql(DISPATCH_LEVEL, &Irql);
@@ -547,6 +554,7 @@ PdoD0ToD3(
 
     KeLowerIrql(Irql);
 
+done:
     Trace("(%s) <====\n", __PdoGetName(Pdo));
 }