hidclass: Only access Tail.Overlay.OriginalFileObject when needed.

This commit is contained in:
Rémi Bernon 2024-01-14 18:04:56 +01:00 committed by Alexandre Julliard
parent 677107956f
commit 8db5dec9d2

View file

@ -527,7 +527,6 @@ static NTSTATUS hid_device_xfer_report( BASE_DEVICE_EXTENSION *ext, ULONG code,
NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp)
{ {
struct hid_queue *queue = irp->Tail.Overlay.OriginalFileObject->FsContext;
IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp );
BASE_DEVICE_EXTENSION *ext = device->DeviceExtension; BASE_DEVICE_EXTENSION *ext = device->DeviceExtension;
NTSTATUS status = irp->IoStatus.Status; NTSTATUS status = irp->IoStatus.Status;
@ -637,7 +636,10 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp)
if (irpsp->Parameters.DeviceIoControl.InputBufferLength != sizeof(ULONG)) if (irpsp->Parameters.DeviceIoControl.InputBufferLength != sizeof(ULONG))
status = STATUS_BUFFER_OVERFLOW; status = STATUS_BUFFER_OVERFLOW;
else else
{
struct hid_queue *queue = irp->Tail.Overlay.OriginalFileObject->FsContext;
status = hid_queue_resize( queue, *(ULONG *)irp->AssociatedIrp.SystemBuffer ); status = hid_queue_resize( queue, *(ULONG *)irp->AssociatedIrp.SystemBuffer );
}
break; break;
} }
case IOCTL_GET_NUM_DEVICE_INPUT_BUFFERS: case IOCTL_GET_NUM_DEVICE_INPUT_BUFFERS:
@ -646,6 +648,7 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp)
status = STATUS_BUFFER_TOO_SMALL; status = STATUS_BUFFER_TOO_SMALL;
else else
{ {
struct hid_queue *queue = irp->Tail.Overlay.OriginalFileObject->FsContext;
*(ULONG *)irp->AssociatedIrp.SystemBuffer = queue->length; *(ULONG *)irp->AssociatedIrp.SystemBuffer = queue->length;
irp->IoStatus.Information = sizeof(ULONG); irp->IoStatus.Information = sizeof(ULONG);
status = STATUS_SUCCESS; status = STATUS_SUCCESS;