|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] Correct return codes during racy destruction.
Signed-off-by: Martin Harvey <martin.harvey@xxxxxxxxxx>
---
src/xenbus/driver.c | 12 ++++++++++++
src/xenbus/fdo.c | 2 +-
src/xenbus/pdo.c | 2 +-
src/xenfilt/driver.c | 12 ++++++++++++
4 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/xenbus/driver.c b/src/xenbus/driver.c
index e07de55..167dd22 100644
--- a/src/xenbus/driver.c
+++ b/src/xenbus/driver.c
@@ -760,8 +760,20 @@ DriverDispatch(
ASSERT3P(Dx->DeviceObject, ==, DeviceObject);
if (Dx->DevicePnpState == Deleted) {
+ PIO_STACK_LOCATION StackLocation = IoGetCurrentIrpStackLocation(Irp);
+ UCHAR MajorFunction = StackLocation->MajorFunction;
+ UCHAR MinorFunction = StackLocation->MinorFunction;
status = STATUS_NO_SUCH_DEVICE;
+ if (MajorFunction == IRP_MJ_PNP) {
+ if ((MinorFunction == IRP_MN_SURPRISE_REMOVAL) ||
+ (MinorFunction == IRP_MN_REMOVE_DEVICE)) {
+ /* FDO and PDO deletions can block after being marked deleted,
but before IoDeleteDevice */
+ status = STATUS_SUCCESS;
+ }
+ BUG_ON((MinorFunction == IRP_MN_CANCEL_REMOVE_DEVICE) ||
(MinorFunction == IRP_MN_CANCEL_STOP_DEVICE));
+ }
+
Irp->IoStatus.Status = status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
goto done;
diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index d08c518..4242f07 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -4708,7 +4708,7 @@ FdoDispatchPnp(
MinorFunction,
PnpMinorFunctionName(MinorFunction));
- switch (StackLocation->MinorFunction) {
+ switch (MinorFunction) {
case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
status = FdoFilterResourceRequirements(Fdo, Irp);
break;
diff --git a/src/xenbus/pdo.c b/src/xenbus/pdo.c
index efd29dc..fe88d5d 100644
--- a/src/xenbus/pdo.c
+++ b/src/xenbus/pdo.c
@@ -1609,7 +1609,7 @@ PdoDispatchPnp(
MinorFunction,
PnpMinorFunctionName(MinorFunction));
- switch (StackLocation->MinorFunction) {
+ switch (MinorFunction) {
case IRP_MN_START_DEVICE:
status = PdoStartDevice(Pdo, Irp);
break;
diff --git a/src/xenfilt/driver.c b/src/xenfilt/driver.c
index 8a8396e..894fd24 100644
--- a/src/xenfilt/driver.c
+++ b/src/xenfilt/driver.c
@@ -862,8 +862,20 @@ DriverDispatch(
ASSERT3P(Dx->DeviceObject, ==, DeviceObject);
if (Dx->DevicePnpState == Deleted) {
+ PIO_STACK_LOCATION StackLocation = IoGetCurrentIrpStackLocation(Irp);
+ UCHAR MajorFunction = StackLocation->MajorFunction;
+ UCHAR MinorFunction = StackLocation->MinorFunction;
status = STATUS_NO_SUCH_DEVICE;
+ if (MajorFunction == IRP_MJ_PNP) {
+ if ((MinorFunction == IRP_MN_SURPRISE_REMOVAL) ||
+ (MinorFunction == IRP_MN_REMOVE_DEVICE)) {
+ /* FDO and PDO deletions can block after being marked deleted,
but before IoDeleteDevice */
+ status = STATUS_SUCCESS;
+ }
+ BUG_ON((MinorFunction == IRP_MN_CANCEL_REMOVE_DEVICE) ||
(MinorFunction == IRP_MN_CANCEL_STOP_DEVICE));
+ }
+
Irp->IoStatus.Status = status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
goto done;
--
2.25.0.windows.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |