[UNIATA] Fix Memory leak while claiming PCI IDE controller (#5053)

HalAssignSlotResources will allocate a new resource list which the caller must free.
This commit is contained in:
Atharva Kulkarni 2023-03-22 03:31:18 +05:30 committed by GitHub
parent cb454ef9ed
commit 08248e83a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;