]> xenbits.xensource.com Git - people/pauldu/xeniface.git/commitdiff
Call XenIfaceCleanup from IRP_MJ_CLEANUP
authorOwen Smith <owen.smith@citrix.com>
Mon, 27 Jun 2016 09:40:24 +0000 (10:40 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Tue, 5 Jul 2016 16:54:13 +0000 (17:54 +0100)
XenIfaceCleanup was not called which meant that some watches, event
channels and grant entries were not cleaned up on closing the device
handle and required explicit cleanup. Add a IRP handler to call
XenIfaceCleanup from the IRP_MJ_CLEANUP for a specific FileObject.
This ensures all watches, event channels and grant entries are
destroyed in the event of the caller crashing or not gracefullly
cleaning up objects.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
src/xeniface/fdo.c

index fa14b5b20bac010920b0948d37c2e9d7fd99be20..ba8d19a8c2f935bd0416a6dfbaf766c3886ac1e3 100644 (file)
@@ -2300,6 +2300,25 @@ FdoDispatchSystemControl(
     return status;
 }
 
+static DECLSPEC_NOINLINE NTSTATUS
+FdoDispatchCleanup(
+    IN  PXENIFACE_FDO   Fdo,
+    IN  PIRP            Irp
+    )
+{
+    PIO_STACK_LOCATION  StackLocation;
+    PFILE_OBJECT        FileObject;
+
+    StackLocation = IoGetCurrentIrpStackLocation(Irp);
+    FileObject = StackLocation->FileObject;
+
+    // XenIfaceCleanup requires PASSIVE_LEVEL as it can call KeFlushQueuedDpcs
+    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+    XenIfaceCleanup(Fdo, FileObject);
+
+    return FdoDispatchComplete(Fdo, Irp);
+}
+
 NTSTATUS
 FdoDispatch(
     IN  PXENIFACE_FDO   Fdo,
@@ -2328,6 +2347,10 @@ FdoDispatch(
         status = FdoDispatchSystemControl(Fdo, Irp);
         break;
 
+    case IRP_MJ_CLEANUP:
+        status = FdoDispatchCleanup(Fdo, Irp);
+        break;
+
     case IRP_MJ_CREATE:
     case IRP_MJ_CLOSE:
     case IRP_MJ_READ: