Skip to content

Commit

Permalink
[viofs] Fix MDL structure memory leak
Browse files Browse the repository at this point in the history
Resolves: https://issues.redhat.com/browse/RHEL-19069
Resolves: #1004

Remarks from https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-mmallocatepagesformdlex

The caller must use MmFreePagesFromMdl to release the
memory pages that are described by an MDL that was created
by MmAllocatePagesForMdlEx. After calling MmFreePagesFromMdl,
the caller must also call ExFreePool to release the memory
that is allocated for the MDL structure.

Signed-off-by: Kostiantyn Kostiuk <konstantin@daynix.com>
  • Loading branch information
kostyanf14 authored and YanVugenfirer committed Jan 14, 2024
1 parent ac8043e commit f604edf
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions viofs/pci/viofs.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,15 @@ void FreeVirtFsRequest(IN PVIRTIO_FS_REQUEST Request)
if (Request->InputBuffer != NULL)
{
MmFreePagesFromMdl(Request->InputBuffer);
ExFreePool(Request->InputBuffer);
Request->InputBuffer = NULL;
Request->InputBufferLength = 0;
}

if (Request->OutputBuffer != NULL)
{
MmFreePagesFromMdl(Request->OutputBuffer);
ExFreePool(Request->OutputBuffer);
Request->OutputBuffer = NULL;
Request->OutputBufferLength = 0;
}
Expand Down

0 comments on commit f604edf

Please sign in to comment.