Author: tfaber Date: Thu Nov 28 14:32:04 2013 New Revision: 61113
URL: http://svn.reactos.org/svn/reactos?rev=61113&view=rev Log: [SERIAL] - Fix a race condition
Modified: trunk/reactos/drivers/serial/serial/devctrl.c
Modified: trunk/reactos/drivers/serial/serial/devctrl.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/serial/serial/devct... ============================================================================== --- trunk/reactos/drivers/serial/serial/devctrl.c [iso-8859-1] (original) +++ trunk/reactos/drivers/serial/serial/devctrl.c [iso-8859-1] Thu Nov 28 14:32:04 2013 @@ -827,12 +827,10 @@ Status = STATUS_INVALID_PARAMETER; else { - /* FIXME: Race condition here: - * If an interrupt comes before we can mark the Irp - * as pending, it might be possible to complete the - * Irp before pending it, leading to a crash! */ + IoMarkIrpPending(Irp); + WaitingIrp = InterlockedCompareExchangePointer( - (PVOID)&DeviceExtension->WaitOnMaskIrp, + &DeviceExtension->WaitOnMaskIrp, Irp, NULL);
@@ -841,13 +839,11 @@ { /* Unable to have a 2nd pending IRP for this IOCTL */ WARN_(SERIAL, "Unable to pend a second IRP for IOCTL_SERIAL_WAIT_ON_MASK\n"); - Status = STATUS_INVALID_PARAMETER; + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; + IoCompleteRequest(Irp, IO_NO_INCREMENT); } - else - { - Status = STATUS_PENDING; - /* FIXME: immediately return if a wait event already occurred */ - } + return STATUS_PENDING; } break; }