[AMD Official Use Only - General] Reviewed-by: Abner Chang <abner.ch...@amd.com>
> -----Original Message----- > From: Nickle Wang <nick...@nvidia.com> > Sent: Monday, April 1, 2024 10:18 PM > To: devel@edk2.groups.io > Cc: Chang, Abner <abner.ch...@amd.com>; Igor Kulchytskyy > <ig...@ami.com>; Nick Ramirez <nrami...@nvidia.com> > Subject: [edk2-redfish-client][PATCH v2 2/2] RedfishClientPkg/Features: > release > resources > > Caution: This message originated from an External Source. Use proper caution > when opening attachments, clicking links, or responding. > > > -Release Etag and PendingSettingUri resources. > -Update function header for GetHttpResponseEtag() and > GetHttpResponseLocation(). Caller has to release returned > memory buffer from these two functions. > -Fix typo. > > Signed-off-by: Nickle Wang <nick...@nvidia.com> > Cc: Abner Chang <abner.ch...@amd.com> > Cc: Igor Kulchytskyy <ig...@ami.com> > Cc: Nick Ramirez <nrami...@nvidia.com> > --- > .../Features/Bios/v1_0_9/Common/BiosCommon.c | 2 +- > .../Features/Bios/v1_0_9/Dxe/BiosDxe.c | 20 ++++++++-- > .../BootOption/v1_0_4/Dxe/BootOptionDxe.c | 33 ++++++++++++----- > .../BootOptionCollectionDxe.c | 2 +- > .../v1_13_0/Dxe/ComputerSystemDxe.c | 33 ++++++++++++----- > .../v1_5_0/Dxe/ComputerSystemDxe.c | 33 ++++++++++++----- > .../ComputerSystemCollectionDxe.c | 2 +- > .../Features/Memory/V1_7_1/Dxe/MemoryDxe.c | 37 ++++++++++++++----- > .../MemoryCollectionDxe/MemoryCollectionDxe.c | 2 +- > .../RedfishFeatureUtilityLib.c | 2 + > 10 files changed, 118 insertions(+), 48 deletions(-) > > diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c > b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c > index f40fe215a..5dc97876c 100644 > --- a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c > +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c > @@ -815,7 +815,7 @@ HandleResource ( > > // > // Check and see if target property exist or not even when collection > member > exists. > - // If not, we sill do provision. > + // If not, we still do provision. > // > DEBUG ((REDFISH_DEBUG_TRACE, "%a Check for %s\n", __func__, Uri)); > Status = EdkIIRedfishResourceConfigCheck (&SchemaInfo, Uri, NULL); > diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c > b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c > index bb64ef862..5955917f2 100644 > --- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c > +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c > @@ -158,8 +158,12 @@ RedfishResourceConsumeResource ( > // > // Searching for etag in HTTP response header > // > - Etag = NULL; > - GetHttpResponseEtag (ExpectedResponse, &Etag); > + Etag = NULL; > + Status = GetHttpResponseEtag (ExpectedResponse, &Etag); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n", > __func__)); > + } > + > Status = RedfishConsumeResourceCommon (Private, Private->Json, Etag); > if (EFI_ERROR (Status)) { > DEBUG ((DEBUG_ERROR, "%a: failed to consume resource from: %s: %r\n", > __func__, Private->Uri, Status)); > @@ -338,8 +342,12 @@ RedfishResourceCheck ( > // > // Find etag in HTTP response header > // > - Etag = NULL; > - GetHttpResponseEtag (&Response, &Etag); > + Etag = NULL; > + Status = GetHttpResponseEtag (&Response, &Etag); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n", > __func__)); > + } > + > Status = RedfishCheckResourceCommon (Private, Private->Json, Etag); > if (EFI_ERROR (Status)) { > DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\n", > __func__, Uri, Status)); > @@ -348,6 +356,10 @@ RedfishResourceCheck ( > // > // Release resource > // > + if (Etag != NULL) { > + FreePool (Etag); > + } > + > RedfishHttpFreeResponse (&Response); > Private->Payload = NULL; > > diff --git a/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c > b/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c > index 5a66fe59e..1a1262403 100644 > --- a/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c > +++ b/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c > @@ -122,12 +122,13 @@ RedfishResourceConsumeResource ( > // > // Check and see if "@Redfish.Settings" exist or not. > // > - Status = GetPendingSettings ( > - Private->RedfishService, > - Response.Payload, > - &PendingSettingResponse, > - &PendingSettingUri > - ); > + PendingSettingUri = NULL; > + Status = GetPendingSettings ( > + Private->RedfishService, > + Response.Payload, > + &PendingSettingResponse, > + &PendingSettingUri > + ); > if (!EFI_ERROR (Status)) { > DEBUG ((REDFISH_BOOT_OPTION_DEBUG_TRACE, "%a: @Redfish.Settings > found: %s\n", __func__, PendingSettingUri)); > SetRedfishSettingsObjectsUri (Private->Uri, PendingSettingUri); > @@ -147,8 +148,12 @@ RedfishResourceConsumeResource ( > // > // Find etag in HTTP response header > // > - Etag = NULL; > - GetHttpResponseEtag (ExpectedResponse, &Etag); > + Etag = NULL; > + Status = GetHttpResponseEtag (ExpectedResponse, &Etag); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", > __func__)); > + } > + > Status = RedfishConsumeResourceCommon (Private, Private->Json, Etag); > if (EFI_ERROR (Status)) { > DEBUG ((DEBUG_ERROR, "%a: failed to consume resource from: %s: %r\n", > __func__, Private->Uri, Status)); > @@ -170,6 +175,10 @@ RedfishResourceConsumeResource ( > Private->Json = NULL; > } > > + if (PendingSettingUri != NULL) { > + FreePool (PendingSettingUri); > + } > + > return Status; > } > > @@ -323,8 +332,12 @@ RedfishResourceCheck ( > // > // Find etag in HTTP response header > // > - Etag = NULL; > - GetHttpResponseEtag (&Response, &Etag); > + Etag = NULL; > + Status = GetHttpResponseEtag (&Response, &Etag); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", > __func__)); > + } > + > Status = RedfishCheckResourceCommon (Private, Private->Json, Etag); > if (EFI_ERROR (Status)) { > DEBUG ((REDFISH_BOOT_OPTION_DEBUG_TRACE, "%a: failed to check > resource from: %s: %r\n", __func__, Uri, Status)); > diff --git > a/RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe.c > b/RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe.c > index cd1437f54..79ec739cb 100644 > --- > a/RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe.c > +++ > b/RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe.c > @@ -85,7 +85,7 @@ HandleResource ( > > // > // Check and see if target property exist or not even when collection > member > exists. > - // If not, we sill do provision. > + // If not, we still do provision. > // > DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a Check > for %s\n", __func__, Uri)); > Status = EdkIIRedfishResourceConfigCheck (&SchemaInfo, Uri, NULL); > diff --git > a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemD > xe.c > b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemD > xe.c > index a0c71212b..9c405bb2f 100644 > --- > a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemD > xe.c > +++ > b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemD > xe.c > @@ -125,12 +125,13 @@ RedfishResourceConsumeResource ( > // Check and see if "@Redfish.Settings" exist or not. > // > ZeroMem (&PendingSettingResponse, sizeof (REDFISH_RESPONSE)); > - Status = GetPendingSettings ( > - Private->RedfishService, > - Response.Payload, > - &PendingSettingResponse, > - &PendingSettingUri > - ); > + PendingSettingUri = NULL; > + Status = GetPendingSettings ( > + Private->RedfishService, > + Response.Payload, > + &PendingSettingResponse, > + &PendingSettingUri > + ); > if (!EFI_ERROR (Status)) { > DEBUG ((REDFISH_DEBUG_TRACE, "%a: @Redfish.Settings found: %s\n", > __func__, PendingSettingUri)); > SetRedfishSettingsObjectsUri (Private->Uri, PendingSettingUri); > @@ -151,8 +152,12 @@ RedfishResourceConsumeResource ( > // > // Find etag in HTTP response header > // > - Etag = NULL; > - GetHttpResponseEtag (ExpectedResponse, &Etag); > + Etag = NULL; > + Status = GetHttpResponseEtag (ExpectedResponse, &Etag); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", > __func__)); > + } > + > Status = RedfishConsumeResourceCommon (Private, Private->Json, Etag); > if (EFI_ERROR (Status)) { > DEBUG ((DEBUG_ERROR, "%a: failed to consume resource from: %s: %r\n", > __func__, Private->Uri, Status)); > @@ -177,6 +182,10 @@ RedfishResourceConsumeResource ( > Private->Json = NULL; > } > > + if (PendingSettingUri != NULL) { > + FreePool (PendingSettingUri); > + } > + > return Status; > } > > @@ -330,8 +339,12 @@ RedfishResourceCheck ( > // > // Find etag in HTTP response header > // > - Etag = NULL; > - GetHttpResponseEtag (&Response, &Etag); > + Etag = NULL; > + Status = GetHttpResponseEtag (&Response, &Etag); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", > __func__)); > + } > + > Status = RedfishCheckResourceCommon (Private, Private->Json, Etag); > if (EFI_ERROR (Status)) { > DEBUG ((DEBUG_ERROR, "%a: failed to check resource from: %s: %r\n", > __func__, Uri, Status)); > diff --git > a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDx > e.c > b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDx > e.c > index 494bf59df..a58151f67 100644 > --- > a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDx > e.c > +++ > b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDx > e.c > @@ -126,12 +126,13 @@ RedfishResourceConsumeResource ( > // Check and see if "@Redfish.Settings" exist or not. > // > ZeroMem (&PendingSettingResponse, sizeof (REDFISH_RESPONSE)); > - Status = GetPendingSettings ( > - Private->RedfishService, > - Response.Payload, > - &PendingSettingResponse, > - &PendingSettingUri > - ); > + PendingSettingUri = NULL; > + Status = GetPendingSettings ( > + Private->RedfishService, > + Response.Payload, > + &PendingSettingResponse, > + &PendingSettingUri > + ); > if (!EFI_ERROR (Status)) { > DEBUG ((REDFISH_DEBUG_TRACE, "%a: @Redfish.Settings found: %s\n", > __func__, PendingSettingUri)); > SetRedfishSettingsObjectsUri (Private->Uri, PendingSettingUri); > @@ -152,8 +153,12 @@ RedfishResourceConsumeResource ( > // > // Find etag in HTTP response header > // > - Etag = NULL; > - GetHttpResponseEtag (ExpectedResponse, &Etag); > + Etag = NULL; > + Status = GetHttpResponseEtag (ExpectedResponse, &Etag); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", > __func__)); > + } > + > Status = RedfishConsumeResourceCommon (Private, Private->Json, Etag); > if (EFI_ERROR (Status)) { > DEBUG ((DEBUG_ERROR, "%a: failed to consume resource from: %s: %r\n", > __func__, Private->Uri, Status)); > @@ -178,6 +183,10 @@ RedfishResourceConsumeResource ( > Private->Json = NULL; > } > > + if (PendingSettingUri != NULL) { > + FreePool (PendingSettingUri); > + } > + > return Status; > } > > @@ -331,8 +340,12 @@ RedfishResourceCheck ( > // > // Find etag in HTTP response header > // > - Etag = NULL; > - GetHttpResponseEtag (&Response, &Etag); > + Etag = NULL; > + Status = GetHttpResponseEtag (&Response, &Etag); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", > __func__)); > + } > + > Status = RedfishCheckResourceCommon (Private, Private->Json, Etag); > if (EFI_ERROR (Status)) { > DEBUG ((DEBUG_ERROR, "%a: failed to check resource from: %s: %r\n", > __func__, Uri, Status)); > diff --git > a/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemC > ollectionDxe.c > b/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemC > ollectionDxe.c > index 3deefa824..868bacf02 100644 > --- > a/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemC > ollectionDxe.c > +++ > b/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemC > ollectionDxe.c > @@ -91,7 +91,7 @@ HandleResource ( > > // > // Check and see if target property exist or not even when collection > member > exists. > - // If not, we sill do provision. > + // If not, we still do provision. > // > DEBUG ((REDFISH_DEBUG_TRACE, "%a Check for %s\n", __func__, Uri)); > Status = EdkIIRedfishResourceConfigCheck (&SchemaInfo, Uri, NULL); > diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c > b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c > index f2c0a7735..87ce62c2d 100644 > --- a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c > +++ b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c > @@ -126,12 +126,13 @@ RedfishResourceConsumeResource ( > // Check and see if "@Redfish.Settings" exist or not. > // > ZeroMem (&PendingSettingResponse, sizeof (REDFISH_RESPONSE)); > - Status = GetPendingSettings ( > - Private->RedfishService, > - Response.Payload, > - &PendingSettingResponse, > - &PendingSettingUri > - ); > + PendingSettingUri = NULL; > + Status = GetPendingSettings ( > + Private->RedfishService, > + Response.Payload, > + &PendingSettingResponse, > + &PendingSettingUri > + ); > if (!EFI_ERROR (Status)) { > DEBUG ((REDFISH_DEBUG_TRACE, "%a: @Redfish.Settings found: %s\n", > __func__, PendingSettingUri)); > SetRedfishSettingsObjectsUri (Private->Uri, PendingSettingUri); > @@ -151,8 +152,12 @@ RedfishResourceConsumeResource ( > // > // Find etag in HTTP response header > // > - Etag = NULL; > - GetHttpResponseEtag (ExpectedResponse, &Etag); > + Etag = NULL; > + Status = GetHttpResponseEtag (ExpectedResponse, &Etag); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", > __func__)); > + } > + > Status = RedfishConsumeResourceCommon (Private, Private->Json, Etag); > if (EFI_ERROR (Status)) { > DEBUG ((DEBUG_ERROR, "%a: failed to consume resource from: %s: %r\n", > __func__, Private->Uri, Status)); > @@ -174,6 +179,10 @@ RedfishResourceConsumeResource ( > FreePool (Etag); > } > > + if (PendingSettingUri != NULL) { > + FreePool (PendingSettingUri); > + } > + > return Status; > } > > @@ -327,8 +336,12 @@ RedfishResourceCheck ( > // > // Find etag in HTTP response header > // > - Etag = NULL; > - GetHttpResponseEtag (&Response, &Etag); > + Etag = NULL; > + Status = GetHttpResponseEtag (&Response, &Etag); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", > __func__)); > + } > + > Status = RedfishCheckResourceCommon (Private, Private->Json, Etag); > if (EFI_ERROR (Status)) { > DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\n", > __func__, Uri, Status)); > @@ -337,6 +350,10 @@ RedfishResourceCheck ( > // > // Release resource > // > + if (Etag != NULL) { > + FreePool (Etag); > + } > + > RedfishHttpFreeResponse (&Response); > Private->Payload = NULL; > > diff --git > a/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c > b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c > index 38f28f902..6bf7f6fc5 100644 > --- a/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c > +++ > b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c > @@ -87,7 +87,7 @@ HandleResource ( > > // > // Check and see if target property exist or not even when collection > member > exists. > - // If not, we sill do provision. > + // If not, we still do provision. > // > DEBUG ((REDFISH_DEBUG_TRACE, "%a Check for %s\n", __func__, Uri)); > Status = EdkIIRedfishResourceConfigCheck (&SchemaInfo, Uri, NULL); > diff --git > a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c > b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c > index 2cc079783..2add55921 100644 > --- > a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c > +++ > b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c > @@ -1744,6 +1744,7 @@ RedfishFeatureGetUnifiedArrayTypeConfigureLang ( > > /** > Find "ETag" from either HTTP header or Redfish response. > + It's caller's responsibility to release Etag by calling FreePool(). > > @param[in] Response HTTP response > @param[out] Etag String buffer to return ETag > @@ -1814,6 +1815,7 @@ GetHttpResponseEtag ( > > /** > Find "Location" from either HTTP header or Redfish response. > + It's caller's responsibility to release Location by calling FreePool(). > > @param[in] Response HTTP response > @param[out] Location String buffer to return Location > -- > 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117561): https://edk2.groups.io/g/devel/message/117561 Mute This Topic: https://groups.io/mt/105265012/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-