[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Add check for empty List in FdoCsqPeekNextIrp.

Under certain situations, such as when input is being sent during driver
install or sleep transition, FdoCsqPeekNextIrp can be called with an
empty Fdo->List. In that case, FdoCsqPeekNextIrp dereferences the list
head and returns an invalid IRP; it should check for this error

Signed-off-by: Troy Crosley <troycrosley@xxxxxxxxx>
 src/xenhid/fdo.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/xenhid/fdo.c b/src/xenhid/fdo.c
index c2ef7c8..04d3d7f 100644
--- a/src/xenhid/fdo.c
+++ b/src/xenhid/fdo.c
@@ -123,8 +123,12 @@ FdoCsqPeekNextIrp(
         ListEntry = Irp->Tail.Overlay.ListEntry.Flink;
-    NextIrp = CONTAINING_RECORD(ListEntry, IRP, Tail.Overlay.ListEntry);
     // should walk through the list until a match against Context is found
+    if (ListEntry != &Fdo->List)
+        NextIrp = CONTAINING_RECORD(ListEntry, IRP, Tail.Overlay.ListEntry);
+    else
+        NextIrp = NULL;
     return NextIrp;



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.