Author: janderwald
Date: Sat May 18 20:16:50 2013
New Revision: 59039
URL:
http://svn.reactos.org/svn/reactos?rev=59039&view=rev
Log:
[USB]
- Fix race condition for status change worker routine
CORE-7193 #resolve
- Tested by Thomas Faber (Blame him ;)
Modified:
trunk/reactos/drivers/usb/usbehci/hardware.cpp
trunk/reactos/drivers/usb/usbohci/hardware.cpp
Modified: trunk/reactos/drivers/usb/usbehci/hardware.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbehci/hardwa…
==============================================================================
--- trunk/reactos/drivers/usb/usbehci/hardware.cpp [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbehci/hardware.cpp [iso-8859-1] Sat May 18 20:16:50 2013
@@ -96,7 +96,7 @@
PVOID m_SCEContext; //
status change callback routine context
BOOLEAN m_DoorBellRingInProgress; //
door bell ring in progress
WORK_QUEUE_ITEM m_StatusChangeWorkItem; //
work item for status change callback
- ULONG m_WorkItemActive; //
work item status
+ volatile LONG m_StatusChangeWorkItemStatus; //
work item status
ULONG m_SyncFramePhysAddr; //
periodic frame list physical address
BUS_INTERFACE_STANDARD m_BusInterface; //
pci bus interface
BOOLEAN m_PortResetInProgress[0xF]; //
stores reset in progress (vbox hack)
@@ -1433,13 +1433,13 @@
//
if (QueueSCEWorkItem && This->m_SCECallBack != NULL)
{
- // work item is now active
- This->m_WorkItemActive = TRUE;
-
- //
- // queue work item for processing
- //
- ExQueueWorkItem(&This->m_StatusChangeWorkItem, DelayedWorkQueue);
+ if (InterlockedCompareExchange(&This->m_StatusChangeWorkItemStatus, 1,
0) == 0)
+ {
+ //
+ // queue work item for processing
+ //
+ ExQueueWorkItem(&This->m_StatusChangeWorkItem, DelayedWorkQueue);
+ }
}
}
return;
@@ -1466,8 +1466,10 @@
This->m_SCECallBack(This->m_SCEContext);
}
- // work item is completed
- This->m_WorkItemActive = FALSE;
+ //
+ // reset active status
+ //
+ InterlockedDecrement(&This->m_StatusChangeWorkItemStatus);
}
NTSTATUS
Modified: trunk/reactos/drivers/usb/usbohci/hardware.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbohci/hardwa…
==============================================================================
--- trunk/reactos/drivers/usb/usbohci/hardware.cpp [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbohci/hardware.cpp [iso-8859-1] Sat May 18 20:16:50 2013
@@ -101,6 +101,7 @@
HD_INIT_CALLBACK* m_SCECallBack; //
status change callback routine
PVOID m_SCEContext; //
status change callback routine context
WORK_QUEUE_ITEM m_StatusChangeWorkItem; //
work item for status change callback
+ volatile LONG m_StatusChangeWorkItemStatus; //
work item active status
ULONG m_SyncFramePhysAddr; //
periodic frame list physical address
ULONG m_IntervalValue; //
periodic interval value
};
@@ -1523,10 +1524,13 @@
//
if (QueueSCEWorkItem && This->m_SCECallBack != NULL)
{
- //
- // queue work item for processing
- //
- ExQueueWorkItem(&This->m_StatusChangeWorkItem, DelayedWorkQueue);
+ if (InterlockedCompareExchange(&This->m_StatusChangeWorkItemStatus, 1,
0) == 0)
+ {
+ //
+ // queue work item for processing
+ //
+ ExQueueWorkItem(&This->m_StatusChangeWorkItem, DelayedWorkQueue);
+ }
}
}
}
@@ -1552,6 +1556,10 @@
This->m_SCECallBack(This->m_SCEContext);
}
+ //
+ // reset active status
+ //
+ InterlockedDecrement(&This->m_StatusChangeWorkItemStatus);
}
NTSTATUS