https://git.reactos.org/?p=reactos.git;a=commitdiff;h=08248e83a0babebef805a…
commit 08248e83a0babebef805a0df3bdd0d59b2e7b82e
Author: Atharva Kulkarni <atharvak1910(a)gmail.com>
AuthorDate: Wed Mar 22 03:31:18 2023 +0530
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Mar 22 01:01:18 2023 +0300
[UNIATA] Fix Memory leak while claiming PCI IDE controller (#5053)
HalAssignSlotResources will allocate a new resource list which the caller must free.
---
drivers/storage/ide/uniata/id_probe.cpp | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/storage/ide/uniata/id_probe.cpp
b/drivers/storage/ide/uniata/id_probe.cpp
index 1ca49d248ec..c950e6f9d8f 100644
--- a/drivers/storage/ide/uniata/id_probe.cpp
+++ b/drivers/storage/ide/uniata/id_probe.cpp
@@ -1941,8 +1941,11 @@ UniataClaimLegacyPCIIDE(
)
{
NTSTATUS status;
- PCM_RESOURCE_LIST resourceList = NULL;
UNICODE_STRING devname;
+ PCM_RESOURCE_LIST resourceList = NULL;
+#ifdef __REACTOS__
+ PCM_RESOURCE_LIST oldResList = NULL;
+#endif
KdPrint2((PRINT_PREFIX "UniataClaimLegacyPCIIDE:\n"));
@@ -1970,6 +1973,10 @@ UniataClaimLegacyPCIIDE(
del_do:
IoDeleteDevice(BMList[i].PciIdeDevObj);
BMList[i].PciIdeDevObj = NULL;
+#ifdef __REACTOS__
+ if (oldResList)
+ ExFreePool(oldResList);
+#endif
return status;
}
@@ -1977,6 +1984,10 @@ del_do:
resourceList,
sizeof(CM_RESOURCE_LIST));
+#ifdef __REACTOS__
+ oldResList = resourceList;
+#endif
+
// IoReportDetectedDevice() should be used for WDM OSes
// TODO: check if resourceList is actually used inside HalAssignSlotResources()
@@ -2006,6 +2017,11 @@ del_do:
goto del_do;
}
+#ifdef __REACTOS__
+ ExFreePool(resourceList);
+ ExFreePool(oldResList);
+#endif
+
KdPrint2((PRINT_PREFIX "ok %#x\n", status));
BMList[i].ChanInitOk |= 0x80;