From ebd400d82cce819be085fd431a7f643ac3eebd44 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 7 Aug 2005 11:47:50 +0000 Subject: [PATCH] Fix a race condition in input packet processing. svn path=/trunk/; revision=17160 --- reactos/drivers/input/mouclass/mouclass.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/reactos/drivers/input/mouclass/mouclass.c b/reactos/drivers/input/mouclass/mouclass.c index d38bb29f067..28fee018dc5 100644 --- a/reactos/drivers/input/mouclass/mouclass.c +++ b/reactos/drivers/input/mouclass/mouclass.c @@ -6,9 +6,7 @@ ** The class driver between win32k and the various mouse port drivers - ** TODO: Change interface to win32k to a callback instead of ReadFile IO - Add support for multiple port devices - + ** FIXME: Support IRP cancellation properly. */ #include @@ -26,7 +24,7 @@ BOOLEAN MouseClassCallBack( PMOUSE_INPUT_DATA MouseDataEnd, PULONG ConsumedCount) { PDEVICE_EXTENSION ClassDeviceExtension = ClassDeviceObject->DeviceExtension; - PIRP Irp; + PIRP Irp = NULL; KIRQL OldIrql; PIO_STACK_LOCATION Stack; ULONG InputCount = MouseDataEnd - MouseDataStart; @@ -53,8 +51,6 @@ BOOLEAN MouseClassCallBack( Irp->IoStatus.Information = sizeof(MOUSE_INPUT_DATA); Stack->Parameters.Read.Length = sizeof(MOUSE_INPUT_DATA); - IoStartNextPacket(ClassDeviceObject, FALSE); - IoCompleteRequest(Irp, IO_MOUSE_INCREMENT); ClassDeviceExtension->ReadIsPending = FALSE; /* Skip the packet we just sent away */ @@ -97,6 +93,12 @@ BOOLEAN MouseClassCallBack( DPRINT("MouseClassCallBack() entered, InputCount = %d - DOING NOTHING\n", InputCount); } + if (Irp != NULL) + { + IoStartNextPacket(ClassDeviceObject, FALSE); + IoCompleteRequest(Irp, IO_MOUSE_INCREMENT); + } + DPRINT("Leaving MouseClassCallBack\n"); return TRUE; }