From 0c64b849c8ce817037dcd5e67dac29bdd33971e1 Mon Sep 17 00:00:00 2001 From: Bailey Date: Tue, 5 Jul 2016 19:56:39 +0200 Subject: [PATCH] handle status other than STATUS_PENDING from FsRtlCheckOplock() --- sys/cleanup.c | 8 ++++++-- sys/fileinfo.c | 8 ++++++-- sys/flush.c | 8 ++++++-- sys/read.c | 8 ++++++-- sys/write.c | 18 ++++++++++++++---- 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/sys/cleanup.c b/sys/cleanup.c index 5aebf8b49..04b2af2ba 100644 --- a/sys/cleanup.c +++ b/sys/cleanup.c @@ -119,8 +119,12 @@ Return Value: // if FsRtlCheckOplock returns STATUS_PENDING the IRP has been posted // to service an oplock break and we need to leave now. // - if (status == STATUS_PENDING) { - DDbgPrint(" FsRtlCheckOplock returned STATUS_PENDING\n"); + if (status != STATUS_SUCCESS) { + if (status == STATUS_PENDING) { + DDbgPrint(" FsRtlCheckOplock returned STATUS_PENDING\n"); + } else { + DokanFreeEventContext(eventContext); + } __leave; } diff --git a/sys/fileinfo.c b/sys/fileinfo.c index c45003ce6..e946c65dc 100644 --- a/sys/fileinfo.c +++ b/sys/fileinfo.c @@ -467,8 +467,12 @@ DokanDispatchSetInformation(__in PDEVICE_OBJECT DeviceObject, __in PIRP Irp) { // if FsRtlCheckOplock returns STATUS_PENDING the IRP has been posted // to service an oplock break and we need to leave now. // - if (status == STATUS_PENDING) { - DDbgPrint(" FsRtlCheckOplock returned STATUS_PENDING\n"); + if (status != STATUS_SUCCESS) { + if (status == STATUS_PENDING) { + DDbgPrint(" FsRtlCheckOplock returned STATUS_PENDING\n"); + } else { + DokanFreeEventContext(eventContext); + } __leave; } diff --git a/sys/flush.c b/sys/flush.c index 078462558..025528fbf 100644 --- a/sys/flush.c +++ b/sys/flush.c @@ -85,8 +85,12 @@ DokanDispatchFlush(__in PDEVICE_OBJECT DeviceObject, __in PIRP Irp) { // if FsRtlCheckOplock returns STATUS_PENDING the IRP has been posted // to service an oplock break and we need to leave now. // - if (status == STATUS_PENDING) { - DDbgPrint(" FsRtlCheckOplock returned STATUS_PENDING\n"); + if (status != STATUS_SUCCESS) { + if (status == STATUS_PENDING) { + DDbgPrint(" FsRtlCheckOplock returned STATUS_PENDING\n"); + } else { + DokanFreeEventContext(eventContext); + } __leave; } diff --git a/sys/read.c b/sys/read.c index 99de1c6ae..2396ef9e1 100644 --- a/sys/read.c +++ b/sys/read.c @@ -203,8 +203,12 @@ Return Value: // if FsRtlCheckOplock returns STATUS_PENDING the IRP has been posted // to service an oplock break and we need to leave now. // - if (status == STATUS_PENDING) { - DDbgPrint(" FsRtlCheckOplock returned STATUS_PENDING\n"); + if (status != STATUS_SUCCESS) { + if (status == STATUS_PENDING) { + DDbgPrint(" FsRtlCheckOplock returned STATUS_PENDING\n"); + } else { + DokanFreeEventContext(eventContext); + } __leave; } diff --git a/sys/write.c b/sys/write.c index d10025ca7..b47bffb19 100644 --- a/sys/write.c +++ b/sys/write.c @@ -196,8 +196,12 @@ DokanDispatchWrite(__in PDEVICE_OBJECT DeviceObject, __in PIRP Irp) { // if FsRtlCheckOplock returns STATUS_PENDING the IRP has been posted // to service an oplock break and we need to leave now. // - if (status == STATUS_PENDING) { - DDbgPrint(" FsRtlCheckOplock returned STATUS_PENDING\n"); + if (status != STATUS_SUCCESS) { + if (status == STATUS_PENDING) { + DDbgPrint(" FsRtlCheckOplock returned STATUS_PENDING\n"); + } else { + DokanFreeEventContext(eventContext); + } __leave; } } @@ -248,8 +252,14 @@ DokanDispatchWrite(__in PDEVICE_OBJECT DeviceObject, __in PIRP Irp) { // if FsRtlCheckOplock returns STATUS_PENDING the IRP has been posted // to service an oplock break and we need to leave now. // - if (status == STATUS_PENDING) { - DDbgPrint(" FsRtlCheckOplock returned STATUS_PENDING\n"); + if (status != STATUS_SUCCESS) { + if (status == STATUS_PENDING) { + DDbgPrint(" FsRtlCheckOplock returned STATUS_PENDING\n"); + } else { + DokanFreeEventContext(requestContext); + Irp->Tail.Overlay.DriverContext[DRIVER_CONTEXT_EVENT] = 0; + DokanFreeEventContext(eventContext); + } __leave; } }