summaryrefslogtreecommitdiffstats
path: root/RedfishPkg
diff options
context:
space:
mode:
authorMike Maslenkin <mike.maslenkin@gmail.com>2023-12-22 01:58:12 +0300
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-12-27 00:09:49 +0000
commitf8de39afab5358c05938e89f8f9a1c389dd8e88f (patch)
tree1feb9f575ea2d39ad2adc4a46b91e6d5007021ac /RedfishPkg
parentd1c21f8d557f01cd82e06d6b9b6900dec8e6b373 (diff)
downloadedk2-f8de39afab5358c05938e89f8f9a1c389dd8e88f.tar.gz
edk2-f8de39afab5358c05938e89f8f9a1c389dd8e88f.tar.bz2
edk2-f8de39afab5358c05938e89f8f9a1c389dd8e88f.zip
RedfishDiscoverDxe: add a helper function deallocating string resources.
This patch adds a handy helper function deallocating resources from the EFI_REDFISH_DISCOVERED_INFORMATION structure instance. Cc: Nickle Wang <nicklew@nvidia.com> Cc: Igor Kulchytskyy <igork@ami.com> Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com> Reviewed-by: Abner Chang <abner.chang@amd.com>
Diffstat (limited to 'RedfishPkg')
-rw-r--r--RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c68
1 files changed, 44 insertions, 24 deletions
diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index e673de8ef7..0f1c056175 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -713,6 +713,49 @@ DiscoverRedfishHostInterface (
}
/**
+ The function releases particular strings into the structure instance.
+
+ @param[in] Information EFI_REDFISH_DISCOVERED_INFORMATION
+
+**/
+STATIC
+VOID
+FreeInformationData (
+ IN EFI_REDFISH_DISCOVERED_INFORMATION *Information
+ )
+{
+ if (Information->Location != NULL) {
+ FreePool (Information->Location);
+ Information->Location = NULL;
+ }
+
+ if (Information->Uuid != NULL) {
+ FreePool (Information->Uuid);
+ Information->Uuid = NULL;
+ }
+
+ if (Information->Os != NULL) {
+ FreePool (Information->Os);
+ Information->Os = NULL;
+ }
+
+ if (Information->OsVersion != NULL) {
+ FreePool (Information->OsVersion);
+ Information->OsVersion = NULL;
+ }
+
+ if (Information->Product != NULL) {
+ FreePool (Information->Product);
+ Information->Product = NULL;
+ }
+
+ if (Information->ProductVer != NULL) {
+ FreePool (Information->ProductVer);
+ Information->ProductVer = NULL;
+ }
+}
+
+/**
The function initializes particular strings into the structure instance.
@param[in] Information EFI_REDFISH_DISCOVERED_INFORMATION
@@ -1514,30 +1557,7 @@ RedfishServiceReleaseService (
do {
if (DiscoveredRedfishInstance->Instance == ThisRedfishInstance) {
RemoveEntryList (&DiscoveredRedfishInstance->NextInstance);
- if (ThisRedfishInstance->Information.Location != NULL) {
- FreePool (ThisRedfishInstance->Information.Location);
- }
-
- if (ThisRedfishInstance->Information.Uuid != NULL) {
- FreePool (ThisRedfishInstance->Information.Uuid);
- }
-
- if (ThisRedfishInstance->Information.Os != NULL) {
- FreePool (ThisRedfishInstance->Information.Os);
- }
-
- if (ThisRedfishInstance->Information.OsVersion != NULL) {
- FreePool (ThisRedfishInstance->Information.OsVersion);
- }
-
- if (ThisRedfishInstance->Information.Product != NULL) {
- FreePool (ThisRedfishInstance->Information.Product);
- }
-
- if (ThisRedfishInstance->Information.ProductVer != NULL) {
- FreePool (ThisRedfishInstance->Information.ProductVer);
- }
-
+ FreeInformationData (&ThisRedfishInstance->Information);
FreePool ((VOID *)ThisRedfishInstance);
goto ReleaseNext;
}