[PATCH 5/5] winebus.sys: Handle IRP_MN_SURPRISE_REMOVAL and set removed flag.

Rémi Bernon rbernon at codeweavers.com
Mon Jun 28 05:22:58 CDT 2021


Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/winebus.sys/main.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c
index 897be25ed51..f3e63e87aa2 100644
--- a/dlls/winebus.sys/main.c
+++ b/dlls/winebus.sys/main.c
@@ -374,10 +374,6 @@ void bus_unlink_hid_device(DEVICE_OBJECT *device)
     EnterCriticalSection(&device_list_cs);
     list_remove(&pnp_device->entry);
     LeaveCriticalSection(&device_list_cs);
-
-    EnterCriticalSection(&ext->cs);
-    ext->removed = TRUE;
-    LeaveCriticalSection(&ext->cs);
 }
 
 void bus_remove_hid_device(DEVICE_OBJECT *device)
@@ -700,11 +696,21 @@ static NTSTATUS pdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
             status = STATUS_SUCCESS;
             break;
 
+        case IRP_MN_SURPRISE_REMOVAL:
+            EnterCriticalSection(&ext->cs);
+            remove_pending_irps(device);
+            ext->removed = TRUE;
+            LeaveCriticalSection(&ext->cs);
+            break;
+
         case IRP_MN_REMOVE_DEVICE:
         {
             struct pnp_device *pnp_device = ext->pnp_device;
 
+            EnterCriticalSection(&ext->cs);
             remove_pending_irps(device);
+            ext->removed = TRUE;
+            LeaveCriticalSection(&ext->cs);
 
             ext->vtbl->free_device(device);
 
-- 
2.32.0




More information about the wine-devel mailing list