-Release Etag and PendingSettingUri resources. -Update function header for GetHttpResponseEtag() and GetHttpResponseLocation(). Caller has to release returned memory buffer from these two functions.
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/Dxe/BiosDxe.c | 20 ++++++++-- .../BootOption/v1_0_4/Dxe/BootOptionDxe.c | 33 ++++++++++++----- .../v1_13_0/Dxe/ComputerSystemDxe.c | 33 ++++++++++++----- .../v1_5_0/Dxe/ComputerSystemDxe.c | 33 ++++++++++++----- .../Features/Memory/V1_7_1/Dxe/MemoryDxe.c | 37 ++++++++++++++----- .../RedfishFeatureUtilityLib.c | 2 + 6 files changed, 114 insertions(+), 44 deletions(-) diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c index 1ca920640..0422d60ff 100644 --- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c @@ -157,8 +157,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)); @@ -337,8 +341,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)); @@ -347,6 +355,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 7501c1a97..ae1fad0a0 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)); Private->Uri = PendingSettingUri; @@ -146,8 +147,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)); @@ -169,6 +174,10 @@ RedfishResourceConsumeResource ( Private->Json = NULL; } + if (PendingSettingUri != NULL) { + FreePool (PendingSettingUri); + } + return Status; } @@ -322,8 +331,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/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.c b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.c index 1235760a1..85dffd434 100644 --- a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.c +++ b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.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)); Private->Uri = PendingSettingUri; @@ -150,8 +151,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)); @@ -176,6 +181,10 @@ RedfishResourceConsumeResource ( Private->Json = NULL; } + if (PendingSettingUri != NULL) { + FreePool (PendingSettingUri); + } + return Status; } @@ -329,8 +338,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/ComputerSystemDxe.c b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c index 5207362da..e4a2f1566 100644 --- a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c +++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.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)); 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/Memory/V1_7_1/Dxe/MemoryDxe.c b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c index c4a363cdf..01a77d938 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)); Private->Uri = PendingSettingUri; @@ -150,8 +151,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)); @@ -173,6 +178,10 @@ RedfishResourceConsumeResource ( FreePool (Etag); } + if (PendingSettingUri != NULL) { + FreePool (PendingSettingUri); + } + return Status; } @@ -326,8 +335,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)); @@ -336,6 +349,10 @@ RedfishResourceCheck ( // // Release resource // + if (Etag != NULL) { + FreePool (Etag); + } + RedfishHttpFreeResponse (&Response); Private->Payload = NULL; diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c index cc2b37b79..2e0fbf197 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c @@ -1738,6 +1738,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 @@ -1808,6 +1809,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 (#116763): https://edk2.groups.io/g/devel/message/116763 Mute This Topic: https://groups.io/mt/104927846/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-