From f604edf27b78b75e919bd0b85ffded8b11f3687d Mon Sep 17 00:00:00 2001 From: Kostiantyn Kostiuk Date: Wed, 10 Jan 2024 04:24:23 -0800 Subject: [PATCH] [viofs] Fix MDL structure memory leak Resolves: https://issues.redhat.com/browse/RHEL-19069 Resolves: https://github.com/virtio-win/kvm-guest-drivers-windows/issues/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 --- viofs/pci/viofs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/viofs/pci/viofs.c b/viofs/pci/viofs.c index dd5fe3580..948f005c7 100644 --- a/viofs/pci/viofs.c +++ b/viofs/pci/viofs.c @@ -238,6 +238,7 @@ void FreeVirtFsRequest(IN PVIRTIO_FS_REQUEST Request) if (Request->InputBuffer != NULL) { MmFreePagesFromMdl(Request->InputBuffer); + ExFreePool(Request->InputBuffer); Request->InputBuffer = NULL; Request->InputBufferLength = 0; } @@ -245,6 +246,7 @@ void FreeVirtFsRequest(IN PVIRTIO_FS_REQUEST Request) if (Request->OutputBuffer != NULL) { MmFreePagesFromMdl(Request->OutputBuffer); + ExFreePool(Request->OutputBuffer); Request->OutputBuffer = NULL; Request->OutputBufferLength = 0; }