[NTOSKRNL]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Thu, 25 Oct 2012 14:27:02 +0000 (14:27 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Thu, 25 Oct 2012 14:27:02 +0000 (14:27 +0000)
- Dereference the correct device object in the power completion routine
- Fixes crash with ftdibus.sys

svn path=/trunk/; revision=57615

reactos/ntoskrnl/po/power.c

index 3ccb9ba..b174e20 100644 (file)
@@ -21,6 +21,7 @@ typedef struct _REQUEST_POWER_ITEM
     PREQUEST_POWER_COMPLETE CompletionRoutine;
     POWER_STATE PowerState;
     PVOID Context;
     PREQUEST_POWER_COMPLETE CompletionRoutine;
     POWER_STATE PowerState;
     PVOID Context;
+    PDEVICE_OBJECT TopDeviceObject;
 } REQUEST_POWER_ITEM, *PREQUEST_POWER_ITEM;
 
 typedef struct _POWER_STATE_TRAVERSE_CONTEXT
 } REQUEST_POWER_ITEM, *PREQUEST_POWER_ITEM;
 
 typedef struct _POWER_STATE_TRAVERSE_CONTEXT
@@ -56,10 +57,10 @@ PopRequestPowerIrpCompletion(IN PDEVICE_OBJECT DeviceObject,
                                         RequestPowerItem->Context,
                                         &Irp->IoStatus);
 
                                         RequestPowerItem->Context,
                                         &Irp->IoStatus);
 
-    ExFreePool(Context);
-
     IoFreeIrp(Irp);
     IoFreeIrp(Irp);
-    ObDereferenceObject(DeviceObject);
+
+    ObDereferenceObject(RequestPowerItem->TopDeviceObject);
+    ExFreePool(Context);
 
     return STATUS_MORE_PROCESSING_REQUIRED;
 }
 
     return STATUS_MORE_PROCESSING_REQUIRED;
 }
@@ -573,6 +574,7 @@ PoRequestPowerIrp(IN PDEVICE_OBJECT DeviceObject,
     RequestPowerItem->CompletionRoutine = CompletionFunction;
     RequestPowerItem->PowerState = PowerState;
     RequestPowerItem->Context = Context;
     RequestPowerItem->CompletionRoutine = CompletionFunction;
     RequestPowerItem->PowerState = PowerState;
     RequestPowerItem->Context = Context;
+    RequestPowerItem->TopDeviceObject = TopDeviceObject;
   
     if (pIrp != NULL)
         *pIrp = Irp;
   
     if (pIrp != NULL)
         *pIrp = Irp;