MdeModulePkg/Core/Dxe: Fix memory leak issue in FwVolBlock.c

FvbDev->LbaCache must be freed on error path before freeing FvbDev.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Mike Maslenkin 2023-08-31 17:10:32 -07:00 committed by mergify[bot]
parent f18ec60fa4
commit cc26a2cb31
1 changed files with 2 additions and 0 deletions

View File

@ -551,6 +551,7 @@ ProduceFVBProtocolOnBuffer (
//
FvbDev->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)AllocateCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH), &mFvMemmapDevicePathTemplate);
if (FvbDev->DevicePath == NULL) {
FreePool (FvbDev->LbaCache);
FreePool (FvbDev);
return EFI_OUT_OF_RESOURCES;
}
@ -563,6 +564,7 @@ ProduceFVBProtocolOnBuffer (
//
FvbDev->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)AllocateCopyPool (sizeof (FV_PIWG_DEVICE_PATH), &mFvPIWGDevicePathTemplate);
if (FvbDev->DevicePath == NULL) {
FreePool (FvbDev->LbaCache);
FreePool (FvbDev);
return EFI_OUT_OF_RESOURCES;
}