[BOOT:MM] Fix descriptor memory leaks
Sometimes when handling MmMdAddDescriptorToList() errors, descriptors were not freed with MmMdFreeDescriptor().
This commit is contained in:
parent
65e33fdad5
commit
43c6c75710
@ -421,6 +421,7 @@ Return Value:
|
|||||||
|
|
||||||
Status = MmMdAddDescriptorToList(Mdl, NtDescriptor, MDL_OPERATION_FLAGS_TRUNCATE);
|
Status = MmMdAddDescriptorToList(Mdl, NtDescriptor, MDL_OPERATION_FLAGS_TRUNCATE);
|
||||||
if (!NT_SUCCESS(Status)) {
|
if (!NT_SUCCESS(Status)) {
|
||||||
|
MmMdFreeDescriptor(NtDescriptor);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,6 +457,7 @@ Return Value:
|
|||||||
|
|
||||||
Status = MmMdAddDescriptorToList(Mdl, NtDescriptor, MDL_OPERATION_FLAGS_TRUNCATE);
|
Status = MmMdAddDescriptorToList(Mdl, NtDescriptor, MDL_OPERATION_FLAGS_TRUNCATE);
|
||||||
if (!NT_SUCCESS(Status)) {
|
if (!NT_SUCCESS(Status)) {
|
||||||
|
MmMdFreeDescriptor(NtDescriptor);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,6 +488,7 @@ Return Value:
|
|||||||
|
|
||||||
Status = MmMdAddDescriptorToList(Mdl, NtDescriptor, MDL_OPERATION_FLAGS_TRUNCATE);
|
Status = MmMdAddDescriptorToList(Mdl, NtDescriptor, MDL_OPERATION_FLAGS_TRUNCATE);
|
||||||
if (!NT_SUCCESS(Status)) {
|
if (!NT_SUCCESS(Status)) {
|
||||||
|
MmMdFreeDescriptor(NtDescriptor);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -507,6 +510,7 @@ Return Value:
|
|||||||
|
|
||||||
Status = MmMdAddDescriptorToList(Mdl, NtDescriptor, MDL_OPERATION_FLAGS_TRUNCATE);
|
Status = MmMdAddDescriptorToList(Mdl, NtDescriptor, MDL_OPERATION_FLAGS_TRUNCATE);
|
||||||
if (!NT_SUCCESS(Status)) {
|
if (!NT_SUCCESS(Status)) {
|
||||||
|
MmMdFreeDescriptor(NtDescriptor);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -568,6 +572,7 @@ Return Value:
|
|||||||
|
|
||||||
Status = MmMdAddDescriptorToList(Mdl, NtDescriptor, MDL_OPERATION_FLAGS_TRUNCATE);
|
Status = MmMdAddDescriptorToList(Mdl, NtDescriptor, MDL_OPERATION_FLAGS_TRUNCATE);
|
||||||
if (!NT_SUCCESS(Status)) {
|
if (!NT_SUCCESS(Status)) {
|
||||||
|
MmMdFreeDescriptor(NtDescriptor);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,6 +152,7 @@ Return Value:
|
|||||||
--*/
|
--*/
|
||||||
|
|
||||||
{
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
PMEMORY_DESCRIPTOR PrevDescriptor, NextDescriptor, NewDescriptor;
|
PMEMORY_DESCRIPTOR PrevDescriptor, NextDescriptor, NewDescriptor;
|
||||||
ULONGLONG DescriptorEnd, PrevDescriptorEnd, NextDescriptorEnd;
|
ULONGLONG DescriptorEnd, PrevDescriptorEnd, NextDescriptorEnd;
|
||||||
ULONGLONG MappedFirstPage;
|
ULONGLONG MappedFirstPage;
|
||||||
@ -186,7 +187,10 @@ Return Value:
|
|||||||
PrevDescriptor->Type
|
PrevDescriptor->Type
|
||||||
);
|
);
|
||||||
if (NewDescriptor != NULL) {
|
if (NewDescriptor != NULL) {
|
||||||
MmMdAddDescriptorToList(Mdl, NewDescriptor, Flags);
|
Status = MmMdAddDescriptorToList(Mdl, NewDescriptor, Flags);
|
||||||
|
if (!NT_SUCCESS(Status)) {
|
||||||
|
MmMdFreeDescriptor(NewDescriptor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +246,10 @@ Return Value:
|
|||||||
Descriptor->Type
|
Descriptor->Type
|
||||||
);
|
);
|
||||||
if (NewDescriptor != NULL) {
|
if (NewDescriptor != NULL) {
|
||||||
MmMdAddDescriptorToList(Mdl, NewDescriptor, Flags);
|
Status = MmMdAddDescriptorToList(Mdl, NewDescriptor, Flags);
|
||||||
|
if (!NT_SUCCESS(Status)) {
|
||||||
|
MmMdFreeDescriptor(NewDescriptor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,6 +141,7 @@ Return Value:
|
|||||||
|
|
||||||
Status = MmMdAddDescriptorToList(&MmMdlReservedAllocated, NewDescriptor, 0x00);
|
Status = MmMdAddDescriptorToList(&MmMdlReservedAllocated, NewDescriptor, 0x00);
|
||||||
if (!NT_SUCCESS(Status)) {
|
if (!NT_SUCCESS(Status)) {
|
||||||
|
MmMdFreeDescriptor(NewDescriptor);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user