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

[PATCH] Correct return codes during racy destruction.


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Martin Harvey <Martin.Harvey@xxxxxxxxxx>
  • Date: Tue, 8 Nov 2022 10:43:46 +0000
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Martin Harvey <Martin.Harvey@xxxxxxxxxx>, Martin Harvey <martin.harvey@xxxxxxxxxx>
  • Delivery-date: Tue, 08 Nov 2022 10:44:03 +0000
  • Ironport-data: A9a23:JztVqK29G5YCyPeLmPbD5Ytxkn2cJEfYwER7XKvMYLTBsI5bpzMPx 2dNWm+AOv2LYzH3c9kgPoq09R8DvJ6ByddmSlNppC1hF35El5HIVI+TRqvS04F+DeWYFR46s J9OAjXkBJppJpMJjk71atANlVEliefTAOK5ULSfUsxIbVcMYD87jh5+kPIOjIdtgNyoayuAo tq3qMDEULOf82cc3lk8tuTS9nuDgNyo4GlC5wVmNagS1LPjvyJ94Kw3dPnZw0TQGuG4LsbiL 87fwbew+H/u/htFIrtJRZ6iLyXm6paLVeS/oiI+t5qK23CulQRrukoPD9IOaF8/ttm8t4sZJ OOhF3CHYVxB0qXkwIzxWvTDes10FfUuFLTveRBTvSEPpqFvnrSFL/hGVSkL0YMkFulfAUxlx eA8ATY0MxWS3ei0m42RWLRQr5F2RCXrFNt3VnBIyDjYCbAtQIzZQrWM7thdtNsyrpkQR7CEP ZNfMGcxKkSbC/FMEg5/5JYWme6ymnj5NT1RskyYtII84nTJzRw327/oWDbQUozWHpoIwhfGz o7A11rXDCEfNO208DiUqi+LgvGXkyWlaLtHQdVU8dY12QbOlwT/EiY+Slq95OGnz0KzRd9bA 0gV4TY167g/8lSxSdvwVAH+p2SL1iPwQPIJTbd8slvUjPOJvUDJXQDoUwKtdvQmmeQGWRgD0 GbUmsKzDz40j5eHFE60o+L8QSyJBQAZKmoLZCkhRAQD4sX+rIxbsi8jXuqPA4bu0ISrRGiYL ySi6XFn2u5N1ZJjO7CTpwivvt66mnTeoufZDC3zV3nt0A52bZXNi2eAuQmCtqYowGp0ozC8U Jk4dyq2tr5m4XKlznblrAAx8FaBtp643MX02wIHInXY323FFr7KVdk4DMtCDEloKN0YXjTif VXevwhcjLcKYiX1PfMpOtrpUZp6pUQFKTgCfqmKBuein7ArLFPXlM2QTRL4M5/RfLgEzvhkZ MbznTeEBncGE6V3pAdatM9EuYLGB0kWmwvueHwM50/+gOLDOCbMEe1t3ZnnRrlR0Z5oaT79q 753X/ZmAT0GOAEiSkE7KbIuEG0=
  • Ironport-hdrordr: A9a23:xuQ6KKtJHknz52f68RauVy3y7skDfNV00zEX/kB9WHVpmszxra +TdZMgpHrJYVcqKRYdcL+7WZVoLUmwyXcX2/hyAV7BZmnbUQKTRekIh7cKqweQfxEWndQy6U 4PScRD4aXLfDtHsfo=
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

Signed-off-by: Martin Harvey <martin.harvey@xxxxxxxxxx>
---
 src/xencons/driver.c | 12 ++++++++++++
 src/xencons/fdo.c    |  2 +-
 src/xencons/pdo.c    |  2 +-
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/xencons/driver.c b/src/xencons/driver.c
index 5a4d1d3..2cec799 100644
--- a/src/xencons/driver.c
+++ b/src/xencons/driver.c
@@ -194,8 +194,20 @@ Dispatch(
     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/xencons/fdo.c b/src/xencons/fdo.c
index 9904249..5640db9 100644
--- a/src/xencons/fdo.c
+++ b/src/xencons/fdo.c
@@ -2021,7 +2021,7 @@ FdoDispatchPnp(
           MinorFunction,
           PnpMinorFunctionName(MinorFunction));
 
-    switch (StackLocation->MinorFunction) {
+    switch (MinorFunction) {
     case IRP_MN_START_DEVICE:
         status = FdoStartDevice(Fdo, Irp);
         break;
diff --git a/src/xencons/pdo.c b/src/xencons/pdo.c
index d7db389..c9c313d 100644
--- a/src/xencons/pdo.c
+++ b/src/xencons/pdo.c
@@ -1271,7 +1271,7 @@ PdoDispatchPnp(
           MinorFunction,
           PnpMinorFunctionName(MinorFunction));
 
-    switch (StackLocation->MinorFunction) {
+    switch (MinorFunction) {
     case IRP_MN_START_DEVICE:
         status = PdoStartDevice(Pdo, Irp);
         break;
-- 
2.25.0.windows.1




 


Rackspace

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