FvbDev->LbaCache must be freed on error path before deallocating FvbDev.
Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
---
MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c b/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c
index d81334ce24d1..9f5f40e5cd49 100644
--- a/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c
+++ b/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c
@@ -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;
}
--
2.32.0 (Apple Git-132)
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108222): https://edk2.groups.io/g/devel/message/108222
Mute This Topic: https://groups.io/mt/101085565/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
+Jian
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
> -----Original Message-----
> From: Mike Maslenkin <mike.maslenkin@gmail.com>
> Sent: Thursday, August 31, 2023 5:11 PM
> To: devel@edk2.groups.io
> Cc: Bi, Dandan <dandan.bi@intel.com>; Gao, Liming
> <gaoliming@byosoft.com.cn>; Kinney, Michael D <michael.d.kinney@intel.com>;
> Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Mike Maslenkin
> <mike.maslenkin@gmail.com>
> Subject: [PATCH 2/2] MdeModulePkg/Core/Dxe: Fix memory leak issue in
> FwVolBlock.c
>
> FvbDev->LbaCache must be freed on error path before deallocating FvbDev.
>
> Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
> ---
> MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c
> b/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c
> index d81334ce24d1..9f5f40e5cd49 100644
> --- a/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c
> +++ b/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c
> @@ -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;
>
> }
>
> --
> 2.32.0 (Apple Git-132)
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108465): https://edk2.groups.io/g/devel/message/108465
Mute This Topic: https://groups.io/mt/101085565/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076/xyzzy [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2026 Red Hat, Inc.