From 31638dffc715d7d3cffd75985ce5a355a97a0225 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 8 Mar 2010 04:58:49 +0000 Subject: [PATCH] [NTOS] IofCompleteRequest: Skip the stack location at the beginning of the loop instead of before and at the end to avoid double skipping of the last valid stack location in certain cases. This prevents the ASSERT in IoSkipCurrentIrpStackLocation to be hit. Note: this leads to a different value of Irp->CurrentLocation and Irp->Tail.Overlay.CurrentStackLocation after the last completion routine has been called. But that should hopefully not make a difference. svn path=/branches/header-work/; revision=45996 --- ntoskrnl/io/iomgr/irp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ntoskrnl/io/iomgr/irp.c b/ntoskrnl/io/iomgr/irp.c index 9ef5f0cb74d..0863f58907b 100644 --- a/ntoskrnl/io/iomgr/irp.c +++ b/ntoskrnl/io/iomgr/irp.c @@ -1217,13 +1217,15 @@ IofCompleteRequest(IN PIRP Irp, ErrorCode = PtrToUlong(LastStackPtr->Parameters.Others.Argument4); } - /* Get the Current Stack and skip it */ + /* Get the Current Stack */ StackPtr = IoGetCurrentIrpStackLocation(Irp); - IoSkipCurrentIrpStackLocation(Irp); /* Loop the Stacks and complete the IRPs */ do { + /* Skip current stack location */ + IoSkipCurrentIrpStackLocation(Irp); + /* Set Pending Returned */ Irp->PendingReturned = StackPtr->Control & SL_PENDING_RETURNED; @@ -1286,10 +1288,9 @@ IofCompleteRequest(IN PIRP Irp, IopClearStackLocation(StackPtr); } - /* Move to next stack location and pointer */ - IoSkipCurrentIrpStackLocation(Irp); + /* Move pointer to next stack location */ StackPtr++; - } while (Irp->CurrentLocation <= (Irp->StackCount + 1)); + } while (Irp->CurrentLocation <= Irp->StackCount); /* Check if the IRP is an associated IRP */ if (Irp->Flags & IRP_ASSOCIATED_IRP)