[USBSTOR] Properly handle IRP_MN_QUERY_DEVICE_RELATIONS(BusRelations) for FDO.

This fixes Driver Verifier warnings
This commit is contained in:
Victor Perevertkin 2019-06-11 02:50:43 +03:00
parent 04409942d6
commit da1b08e842

View file

@ -5,6 +5,7 @@
* COPYRIGHT: 2005-2006 James Tabor * COPYRIGHT: 2005-2006 James Tabor
* 2011-2012 Michael Martin (michael.martin@reactos.org) * 2011-2012 Michael Martin (michael.martin@reactos.org)
* 2011-2013 Johannes Anderwald (johannes.anderwald@reactos.org) * 2011-2013 Johannes Anderwald (johannes.anderwald@reactos.org)
* 2019 Victor Perevertkin (victor.perevertkin@reactos.org)
*/ */
#include "usbstor.h" #include "usbstor.h"
@ -45,13 +46,9 @@ USBSTOR_FdoHandleDeviceRelations(
IoStack = IoGetCurrentIrpStackLocation(Irp); IoStack = IoGetCurrentIrpStackLocation(Irp);
// check if relation type is BusRelations
if (IoStack->Parameters.QueryDeviceRelations.Type != BusRelations)
{
// FDO always only handles bus relations // FDO always only handles bus relations
return USBSTOR_SyncForwardIrp(DeviceExtension->LowerDeviceObject, Irp); if (IoStack->Parameters.QueryDeviceRelations.Type == BusRelations)
} {
// go through array and count device objects // go through array and count device objects
for (Index = 0; Index < max(DeviceExtension->MaxLUN, 1); Index++) for (Index = 0; Index < max(DeviceExtension->MaxLUN, 1); Index++)
{ {
@ -64,6 +61,9 @@ USBSTOR_FdoHandleDeviceRelations(
DeviceRelations = (PDEVICE_RELATIONS)AllocateItem(PagedPool, sizeof(DEVICE_RELATIONS) + (DeviceCount > 1 ? (DeviceCount-1) * sizeof(PDEVICE_OBJECT) : 0)); DeviceRelations = (PDEVICE_RELATIONS)AllocateItem(PagedPool, sizeof(DEVICE_RELATIONS) + (DeviceCount > 1 ? (DeviceCount-1) * sizeof(PDEVICE_OBJECT) : 0));
if (!DeviceRelations) if (!DeviceRelations)
{ {
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
@ -83,8 +83,12 @@ USBSTOR_FdoHandleDeviceRelations(
} }
Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations; Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
Irp->IoStatus.Status = STATUS_SUCCESS;
}
return STATUS_SUCCESS; IoCopyCurrentIrpStackLocationToNext(Irp);
return IoCallDriver(DeviceExtension->LowerDeviceObject, Irp);
} }
NTSTATUS NTSTATUS
@ -291,9 +295,8 @@ USBSTOR_FdoHandlePnp(
} }
case IRP_MN_QUERY_DEVICE_RELATIONS: case IRP_MN_QUERY_DEVICE_RELATIONS:
{ {
DPRINT("IRP_MN_QUERY_DEVICE_RELATIONS %p\n", DeviceObject); DPRINT("IRP_MN_QUERY_DEVICE_RELATIONS %p Type: %u\n", DeviceObject, IoStack->Parameters.QueryDeviceRelations.Type);
Status = USBSTOR_FdoHandleDeviceRelations(DeviceExtension, Irp); return USBSTOR_FdoHandleDeviceRelations(DeviceExtension, Irp);
break;
} }
case IRP_MN_STOP_DEVICE: case IRP_MN_STOP_DEVICE:
{ {