Skip to content

Commit

Permalink
RedfishClientPkg: refine RedfishExternalResourceResourceFeatureCallback
Browse files Browse the repository at this point in the history
Use local variable for BiosUri passed to HandleResource() to avoid
problems in case of Private->Uri is overriden down the call stack.

Suggested-by: Nickle Wang <[email protected]>
Cc: Abner Chang <[email protected]>
Cc: Nickle Wang <[email protected]>
Cc: Igor Kulchytskyy <[email protected]>
Signed-off-by: Mike Maslenkin <[email protected]>
  • Loading branch information
ghbaccount committed Feb 21, 2024
1 parent acc789d commit 7110d17
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ RedfishExternalResourceResourceFeatureCallback (
REDFISH_SERVICE RedfishService;
REDFISH_RESOURCE_COMMON_PRIVATE *Private;
EFI_STRING ResourceUri;
EFI_STRING BiosUri;

if (FeatureAction != CallbackActionStartOperation) {
return EFI_UNSUPPORTED;
Expand Down Expand Up @@ -707,19 +708,19 @@ RedfishExternalResourceResourceFeatureCallback (
//
// Initialize collection path
//
Private->Uri = RedfishGetUri (ResourceUri);
if (Private->Uri == NULL) {
BiosUri = RedfishGetUri (ResourceUri);
if (BiosUri == NULL) {
ASSERT (FALSE);
FreePool (ResourceUri);
return EFI_OUT_OF_RESOURCES;
}

Status = HandleResource (Private, Private->Uri);
Status = HandleResource (Private, BiosUri);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, process external resource: %a failed: %r\n", __func__, Private->Uri, Status));
DEBUG ((DEBUG_ERROR, "%a, process external resource: %s failed: %r\n", __func__, BiosUri, Status));
}

FreePool (Private->Uri);
FreePool (BiosUri);
FreePool (ResourceUri);
return Status;
}
Expand Down

0 comments on commit 7110d17

Please sign in to comment.