[edk2-devel] [PATCH v2 1/3] RedfishPkg: fix memory leak in HiiUtilityLib

Mike Maslenkin posted 3 patches 2 years, 2 months ago
[edk2-devel] [PATCH v2 1/3] RedfishPkg: fix memory leak in HiiUtilityLib
Posted by Mike Maslenkin 2 years, 2 months ago
Cc: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
---
 RedfishPkg/Library/HiiUtilityLib/HiiUtilityLib.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/RedfishPkg/Library/HiiUtilityLib/HiiUtilityLib.c b/RedfishPkg/Library/HiiUtilityLib/HiiUtilityLib.c
index 168b4459844f..fd322c2086d8 100644
--- a/RedfishPkg/Library/HiiUtilityLib/HiiUtilityLib.c
+++ b/RedfishPkg/Library/HiiUtilityLib/HiiUtilityLib.c
@@ -388,11 +388,13 @@ SetQuestionValue (
       Question->Value.BufferLen = Question->StorageWidth;
       Question->Value.Buffer    = AllocateZeroPool (Question->StorageWidth);
       if (Question->Value.Buffer == NULL) {
+        FreePool (TemString);
         return EFI_OUT_OF_RESOURCES;
       }
 
       CopyMem (Question->Value.Buffer, TemString, StrSize (TemString));
       Src = Question->Value.Buffer;
+      FreePool (TemString);
     } else {
       CopyMem (&Question->Value.Value, &QuestionValue->Value, sizeof (EFI_IFR_TYPE_VALUE));
       Src = (UINT8 *)&Question->Value.Value;
-- 
2.32.0 (Apple Git-132)



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111628): https://edk2.groups.io/g/devel/message/111628
Mute This Topic: https://groups.io/mt/102759077/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v2 1/3] RedfishPkg: fix memory leak in HiiUtilityLib
Posted by Nickle Wang via groups.io 2 years, 2 months ago
Thanks for fixing memory leak issue.

Reviewed-by: Nickle Wang <nicklew@nvidia.com>

Regards,
Nickle

> -----Original Message-----
> From: Mike Maslenkin <mike.maslenkin@gmail.com>
> Sent: Thursday, November 23, 2023 8:01 AM
> To: devel@edk2.groups.io
> Cc: abner.chang@amd.com; Nickle Wang <nicklew@nvidia.com>;
> igork@ami.com
> Subject: [PATCH v2 1/3] RedfishPkg: fix memory leak in HiiUtilityLib
> 
> External email: Use caution opening links or attachments
> 
> 
> Cc: Abner Chang <abner.chang@amd.com>
> Cc: Nickle Wang <nicklew@nvidia.com>
> Cc: Igor Kulchytskyy <igork@ami.com>
> Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
> ---
>  RedfishPkg/Library/HiiUtilityLib/HiiUtilityLib.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/RedfishPkg/Library/HiiUtilityLib/HiiUtilityLib.c
> b/RedfishPkg/Library/HiiUtilityLib/HiiUtilityLib.c
> index 168b4459844f..fd322c2086d8 100644
> --- a/RedfishPkg/Library/HiiUtilityLib/HiiUtilityLib.c
> +++ b/RedfishPkg/Library/HiiUtilityLib/HiiUtilityLib.c
> @@ -388,11 +388,13 @@ SetQuestionValue (
>        Question->Value.BufferLen = Question->StorageWidth;
> 
>        Question->Value.Buffer    = AllocateZeroPool (Question->StorageWidth);
> 
>        if (Question->Value.Buffer == NULL) {
> 
> +        FreePool (TemString);
> 
>          return EFI_OUT_OF_RESOURCES;
> 
>        }
> 
> 
> 
>        CopyMem (Question->Value.Buffer, TemString, StrSize (TemString));
> 
>        Src = Question->Value.Buffer;
> 
> +      FreePool (TemString);
> 
>      } else {
> 
>        CopyMem (&Question->Value.Value, &QuestionValue->Value, sizeof
> (EFI_IFR_TYPE_VALUE));
> 
>        Src = (UINT8 *)&Question->Value.Value;
> 
> --
> 2.32.0 (Apple Git-132)



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111631): https://edk2.groups.io/g/devel/message/111631
Mute This Topic: https://groups.io/mt/102759077/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-