https://git.reactos.org/?p=reactos.git;a=commitdiff;h=631db820587eff59b0ff1…
commit 631db820587eff59b0ff1dee2471806d69a254ec
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sun Jun 2 14:23:59 2019 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sun Jun 2 14:24:35 2019 +0200
[STORPORT] Fix resource list size calculation
---
drivers/storage/port/storport/misc.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/drivers/storage/port/storport/misc.c b/drivers/storage/port/storport/misc.c
index 1c9c73ae661..200682708e1 100644
--- a/drivers/storage/port/storport/misc.c
+++ b/drivers/storage/port/storport/misc.c
@@ -102,7 +102,6 @@ GetResourceListSize(
PCM_RESOURCE_LIST ResourceList)
{
PCM_FULL_RESOURCE_DESCRIPTOR Descriptor;
- INT i;
ULONG Size;
DPRINT1("GetResourceListSize(%p)\n", ResourceList);
@@ -117,20 +116,12 @@ GetResourceListSize(
DPRINT1("ResourceList->Count: %lu\n", ResourceList->Count);
Descriptor = &ResourceList->List[0];
- for (i = 0; i < ResourceList->Count; i++)
- {
- /* Process resources in CM_FULL_RESOURCE_DESCRIPTOR block number ix. */
-
- DPRINT1("PartialResourceList->Count: %lu\n",
Descriptor->PartialResourceList.Count);
- /* Add the size of the current full descriptor */
- Size += sizeof(CM_FULL_RESOURCE_DESCRIPTOR) +
- (Descriptor->PartialResourceList.Count - 1) *
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
+ DPRINT1("PartialResourceList->Count: %lu\n",
Descriptor->PartialResourceList.Count);
- /* Advance to next CM_FULL_RESOURCE_DESCRIPTOR block in memory. */
- Descriptor =
(PCM_FULL_RESOURCE_DESCRIPTOR)(Descriptor->PartialResourceList.PartialDescriptors +
-
Descriptor->PartialResourceList.Count);
- }
+ /* Add the size of the partial descriptors */
+ if (Descriptor->PartialResourceList.Count > 1)
+ Size += (Descriptor->PartialResourceList.Count - 1) *
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
DPRINT1("Size: 0x%lx (%u)\n", Size, Size);
return Size;