From 93c0c968c0edd066cd272c60a15c46d3a8e87fa2 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 4 Apr 2010 02:59:31 +0000 Subject: [PATCH] [NTOSKRNL] - Remove an unused member from PNPROOT_DEVICE - Don't build a bogus resource list if no resources are required - Fixes a crash during resource arbitration because the created resource requirements list was malformed svn path=/trunk/; revision=46710 --- reactos/ntoskrnl/io/pnpmgr/pnproot.c | 50 ++++++++++------------------ 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/reactos/ntoskrnl/io/pnpmgr/pnproot.c b/reactos/ntoskrnl/io/pnpmgr/pnproot.c index 46df601b750..63a3dd59c70 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnproot.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnproot.c @@ -33,7 +33,6 @@ typedef struct _PNPROOT_DEVICE UNICODE_STRING DeviceDescription; // Resource requirement list PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList; - ULONG ResourceRequirementsListSize; // Associated resource list PCM_RESOURCE_LIST ResourceList; ULONG ResourceListSize; @@ -766,18 +765,7 @@ PdoQueryResources( DeviceExtension = (PPNPROOT_PDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - if (DeviceExtension->DeviceInfo->ResourceList == NULL) - { - /* Create an empty resource list */ - ResourceList = ExAllocatePool(PagedPool, sizeof(CM_RESOURCE_LIST)); - if (!ResourceList) - return STATUS_NO_MEMORY; - - ResourceList->Count = 0; - - Irp->IoStatus.Information = (ULONG_PTR)ResourceList; - } - else + if (DeviceExtension->DeviceInfo->ResourceList) { /* Copy existing resource requirement list */ ResourceList = ExAllocatePool( @@ -792,9 +780,14 @@ PdoQueryResources( DeviceExtension->DeviceInfo->ResourceListSize); Irp->IoStatus.Information = (ULONG_PTR)ResourceList; - } - return STATUS_SUCCESS; + return STATUS_SUCCESS; + } + else + { + /* No resources so just return without changing the status */ + return Irp->IoStatus.Status; + } } static NTSTATUS @@ -805,23 +798,10 @@ PdoQueryResourceRequirements( { PPNPROOT_PDO_DEVICE_EXTENSION DeviceExtension; PIO_RESOURCE_REQUIREMENTS_LIST ResourceList; - ULONG ResourceListSize = FIELD_OFFSET(IO_RESOURCE_REQUIREMENTS_LIST, List); DeviceExtension = (PPNPROOT_PDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - if (DeviceExtension->DeviceInfo->ResourceRequirementsList == NULL) - { - /* Create an empty resource list */ - ResourceList = ExAllocatePool(PagedPool, ResourceListSize); - if (!ResourceList) - return STATUS_NO_MEMORY; - - RtlZeroMemory(ResourceList, ResourceListSize); - ResourceList->ListSize = ResourceListSize; - - Irp->IoStatus.Information = (ULONG_PTR)ResourceList; - } - else + if (DeviceExtension->DeviceInfo->ResourceRequirementsList) { /* Copy existing resource requirement list */ ResourceList = ExAllocatePool(PagedPool, DeviceExtension->DeviceInfo->ResourceRequirementsList->ListSize); @@ -832,10 +812,16 @@ PdoQueryResourceRequirements( ResourceList, DeviceExtension->DeviceInfo->ResourceRequirementsList, DeviceExtension->DeviceInfo->ResourceRequirementsList->ListSize); - Irp->IoStatus.Information = (ULONG_PTR)ResourceList; - } - return STATUS_SUCCESS; + Irp->IoStatus.Information = (ULONG_PTR)ResourceList; + + return STATUS_SUCCESS; + } + else + { + /* No resource requirements so just return without changing the status */ + return Irp->IoStatus.Status; + } } static NTSTATUS -- 2.17.1