[edk2-devel] [PATCH] Release build in GCC5 has warning message Wreturn-local-addr in HashPeiLib
JoeX Lu
pen-chunx.lu at intel.com
Thu Apr 27 06:58:30 UTC 2023
CC: Jiewen Yao <jiewen.yao at intel.com>
CC: Jian J Wang <jian.j.wang at intel.com>
Signed-off-by: JoeX Lu <pen-chunx.lu at intel.com>
---
.../HashLibBaseCryptoRouterPei.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c
index eeb424b6c3..bf7a5fc65c 100644
--- a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c
+++ b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c
@@ -84,11 +84,20 @@ InternalCreateHashInterfaceHob (
EFI_GUID *Identifier
)
{
- HASH_INTERFACE_HOB LocalHashInterfaceHob;
+ HASH_INTERFACE_HOB *LocalHashInterfaceHob;
+ HASH_INTERFACE_HOB *HobBuffer;
- ZeroMem (&LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));
- CopyGuid (&LocalHashInterfaceHob.Identifier, Identifier);
- return BuildGuidDataHob (&mHashLibPeiRouterGuid, &LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));
+ HobBuffer = NULL;
+ LocalHashInterfaceHob = AllocateZeroPool (sizeof (HASH_INTERFACE_HOB));
+ if (LocalHashInterfaceHob == NULL) {
+ return NULL;
+ }
+ CopyGuid (&LocalHashInterfaceHob->Identifier, Identifier);
+ HobBuffer = (HASH_INTERFACE_HOB*) BuildGuidDataHob (&mHashLibPeiRouterGuid, LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));
+ if (LocalHashInterfaceHob != NULL) {
+ FreePool (LocalHashInterfaceHob);
+ }
+ return HobBuffer;
}
/**
--
2.31.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103700): https://edk2.groups.io/g/devel/message/103700
Mute This Topic: https://groups.io/mt/98532174/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list