[PATCH] wineusb.sys: Remove device from the device list on PDO removal
Zebediah Figura (she/her)
zfigura at codeweavers.com
Mon Aug 2 15:04:38 CDT 2021
On 8/2/21 11:59 AM, Torge Matthies wrote:
> Fixes a crash when shutting down a prefix.
>
> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51479
> Signed-off-by: Torge Matthies <openglfreak at googlemail.com>
> ---
> dlls/wineusb.sys/wineusb.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/dlls/wineusb.sys/wineusb.c b/dlls/wineusb.sys/wineusb.c
> index fae297915fc..28a36b9f380 100644
> --- a/dlls/wineusb.sys/wineusb.c
> +++ b/dlls/wineusb.sys/wineusb.c
> @@ -413,12 +413,15 @@ static NTSTATUS pdo_pnp(DEVICE_OBJECT *device_obj, IRP *irp)
> break;
>
> case IRP_MN_REMOVE_DEVICE:
> + EnterCriticalSection(&wineusb_cs);
> remove_pending_irps(device);
>
> libusb_unref_device(device->libusb_device);
> libusb_close(device->handle);
>
> + list_remove(&device->entry);
> IoDeleteDevice(device->device_obj);
> + LeaveCriticalSection(&wineusb_cs);
> ret = STATUS_SUCCESS;
> break;
>
>
This looks wrong; the device could have been removed by remove_usb_device().
[1] implies that we actually shouldn't remove the device at all unless
we reported it missing via IRP_MN_QUERY_DEVICE_RELATIONS, which probably
implies that we shouldn't remove and delete the device here, but should
instead remove (and delete?) it from the parent
IRP_MN_SURPRISE_REMOVAL/IRP_MN_REMOVE_DEVICE. It's not particularly
clear though. I'll have to run some tests and check native drivers, but
I won't have access to those until next week.
[1]
https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/removing-a-device-in-a-bus-driver
More information about the wine-devel
mailing list