[edk2-devel] [PATCH v2 04/14] RedfishPkg: RedfishPlatformConfigDxe: reduce memory allocations

Mike Maslenkin posted 14 patches 2 years, 1 month ago
Only 13 patches received!
There is a newer version of this series
[edk2-devel] [PATCH v2 04/14] RedfishPkg: RedfishPlatformConfigDxe: reduce memory allocations
Posted by Mike Maslenkin 2 years, 1 month ago
It's unclear why the new string is allocated as copy of the original
string if its pointer is stored in an array and the original string
is released immediately after the copy is created. All data allocated
in the same pool.

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>
---
 .../RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c       | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
index cbc65ba59408..f970e317b3f6 100644
--- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
+++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
@@ -2057,9 +2057,7 @@ RedfishPlatformConfigProtocolGetConfigureLang (
         TmpString = HiiGetRedfishString (StatementRef->Statement->ParentForm->ParentFormset->HiiHandle, FullSchema, StatementRef->Statement->Description);
         ASSERT (TmpString != NULL);
         if (TmpString != NULL) {
-          TmpConfigureLangList[Index] = AllocateCopyPool (StrSize (TmpString), TmpString);
-          ASSERT (TmpConfigureLangList[Index] != NULL);
-          FreePool (TmpString);
+          TmpConfigureLangList[Index] = TmpString;
           ++Index;
         }
       }
-- 
2.32.0 (Apple Git-132)



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112553): https://edk2.groups.io/g/devel/message/112553
Mute This Topic: https://groups.io/mt/103181039/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v2 04/14] RedfishPkg: RedfishPlatformConfigDxe: reduce memory allocations
Posted by Chang, Abner via groups.io 2 years, 1 month ago
[Public]

Reviewed-by: Abner Chang <abner.chang@amd.com>

> -----Original Message-----
> From: Mike Maslenkin <mike.maslenkin@gmail.com>
> Sent: Friday, December 15, 2023 7:25 AM
> To: devel@edk2.groups.io
> Cc: Chang, Abner <Abner.Chang@amd.com>; nicklew@nvidia.com;
> igork@ami.com; Mike Maslenkin <mike.maslenkin@gmail.com>
> Subject: [PATCH v2 04/14] RedfishPkg: RedfishPlatformConfigDxe: reduce
> memory allocations
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> It's unclear why the new string is allocated as copy of the original
> string if its pointer is stored in an array and the original string
> is released immediately after the copy is created. All data allocated
> in the same pool.
>
> 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>
> ---
>  .../RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c       | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
> b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
> index cbc65ba59408..f970e317b3f6 100644
> --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
> +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
> @@ -2057,9 +2057,7 @@ RedfishPlatformConfigProtocolGetConfigureLang (
>          TmpString = HiiGetRedfishString (StatementRef->Statement-
> >ParentForm->ParentFormset->HiiHandle, FullSchema, StatementRef-
> >Statement->Description);
>
>          ASSERT (TmpString != NULL);
>
>          if (TmpString != NULL) {
>
> -          TmpConfigureLangList[Index] = AllocateCopyPool (StrSize (TmpString),
> TmpString);
>
> -          ASSERT (TmpConfigureLangList[Index] != NULL);
>
> -          FreePool (TmpString);
>
> +          TmpConfigureLangList[Index] = TmpString;
>
>            ++Index;
>
>          }
>
>        }
>
> --
> 2.32.0 (Apple Git-132)



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