From: "Mike Maslenkin" <mike.maslenkin@gmail.com>
To: "Chang, Abner" <Abner.Chang@amd.com>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>,
Nickle Wang <nicklew@nvidia.com>,
Igor Kulchytskyy <igork@ami.com>
Subject: Re: [edk2-devel] [PATCH 2/4] RedfishClientPkg: refine RedfishExternalResourceResourceFeatureCallback
Date: Wed, 21 Feb 2024 22:46:15 +0300 [thread overview]
Message-ID: <CAL77WPAomOeu1SbCd+RcQtkKuSjYbiSeZg=V5AgpnnXHp6_eHg@mail.gmail.com> (raw)
In-Reply-To: <LV8PR12MB9452DE9DB0F5C11265927399EA572@LV8PR12MB9452.namprd12.prod.outlook.com>
On Wed, Feb 21, 2024 at 5:34 AM Chang, Abner <Abner.Chang@amd.com> wrote:
>
> [AMD Official Use Only - General]
>
> > -----Original Message-----
> > From: Mike Maslenkin <mike.maslenkin@gmail.com>
> > Sent: Wednesday, February 21, 2024 8:13 AM
> > To: devel@edk2.groups.io
> > Cc: Mike Maslenkin <mike.maslenkin@gmail.com>; Nickle Wang
> > <nicklew@nvidia.com>; Chang, Abner <Abner.Chang@amd.com>; Igor
> > Kulchytskyy <igork@ami.com>
> > Subject: [PATCH 2/4] RedfishClientPkg: refine
> > RedfishExternalResourceResourceFeatureCallback
> >
> > Caution: This message originated from an External Source. Use proper caution
> > when opening attachments, clicking links, or responding.
> >
> >
> > Use local variable for CollectionUri passed to HandleResource() to avoid
> > problems in case of Private->Uri is overriden down the call stack.
> >
> > Suggested-by: Nickle Wang <nicklew@nvidia.com>
> > Cc: Abner Chang <abner.chang@amd.com>
> > Cc: Nickle Wang <nicklew@nvidia.com>
> > Cc: Igor Kulchytskyy <igork@ami.com>
> > Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
> > ---
> > RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c | 11 ++++++-----
> > 1 file changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> > b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> > index f40f2d85af80..396ec22969b5 100644
> > --- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> > +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> > @@ -670,6 +670,7 @@ RedfishExternalResourceResourceFeatureCallback (
> > REDFISH_SERVICE RedfishService;
> >
> > REDFISH_RESOURCE_COMMON_PRIVATE *Private;
> >
> > EFI_STRING ResourceUri;
> >
> > + EFI_STRING CollectionUri;
> >
> >
> >
> > if (FeatureAction != CallbackActionStartOperation) {
> >
> > return EFI_UNSUPPORTED;
> >
> > @@ -707,19 +708,19 @@ RedfishExternalResourceResourceFeatureCallback
> > (
> > //
> >
> > // Initialize collection path
> >
> > //
> >
> > - Private->Uri = RedfishGetUri (ResourceUri);
> >
> > - if (Private->Uri == NULL) {
> >
> > + CollectionUri = RedfishGetUri (ResourceUri);
>
> I would like to leave this to Nickle to review if there is any impacts of not initializing Private->Uri. Is Private->Uri referred in the later process?
> Apart from above, the naming of CollectionUri is not proper as BiosDxe is not a collection driver. I think the comment of " // Initialize collection path" is a copy & paste error.
>
> Thanks
> Abner
>
Good question about Private->Uri.
It looks like it's safe not to initialize Private->Uri here, because
it is being initialized in every function of
EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL.
That was exactly my previous concern. After this patch only callee
from EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL are dealing with
Private->Uri.
So it could be dropped in favor of additional parameter.
I mean currently EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL function
initializes Private->Uri explicitly, then it is used in function
implementing actual implementation of
EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL. For example:
RedfishResourceConsumeResource->RedfishConsumeResourceCommon,
RedfishResourceConsumeResource->RedfishConsumeResourceCommon,
RedfishResourceProvisioningResource->RedfishProvisioningResourceCommon->{ProvisioningBiosExistResource,ProvisioningBiosResources},
RedfishResourceCheck->RedfishCheckResourceCommon,
RedfishResourceUpdate->RedfishUpdateResourceCommon,
RedfishResourceIdentify->RedfishIdentifyResourceCommon.
So, in all this cases Private->Uri can be passed as a function
argument down to call stack.
And HandleResource() mentioned above calls functions from
EdkIIRedfishResourceConfigLib that in turn calls
EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL implementation, where
Private->Uri is being initialized. See previous paragraph.
I don't think I missed anything.
Regards,
Mike.
> >
> > + if (CollectionUri == NULL) {
> >
> > ASSERT (FALSE);
> >
> > FreePool (ResourceUri);
> >
> > return EFI_OUT_OF_RESOURCES;
> >
> > }
> >
> >
> >
> > - Status = HandleResource (Private, Private->Uri);
> >
> > + Status = HandleResource (Private, CollectionUri);
> >
> > 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__, CollectionUri, Status));
> >
> > }
> >
> >
> >
> > - FreePool (Private->Uri);
> >
> > + FreePool (CollectionUri);
> >
> > FreePool (ResourceUri);
> >
> > return Status;
> >
> > }
> >
> > --
> > 2.32.0 (Apple Git-132)
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115732): https://edk2.groups.io/g/devel/message/115732
Mute This Topic: https://groups.io/mt/104479572/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-02-21 19:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-21 0:12 [edk2-devel] [edk2-redfish-client][PATCH 0/4] RedfishClientPkg: fix memory leaks and refine code Mike Maslenkin
2024-02-21 0:13 ` [edk2-devel] [PATCH 1/4] RedfishClientPkg/RedfishFeatureUtilityLib: fix memory leak on error path Mike Maslenkin
2024-02-21 2:12 ` Chang, Abner via groups.io
2024-02-21 7:23 ` Nickle Wang via groups.io
2024-02-21 0:13 ` [edk2-devel] [PATCH 2/4] RedfishClientPkg: refine RedfishExternalResourceResourceFeatureCallback Mike Maslenkin
2024-02-21 2:34 ` Chang, Abner via groups.io
2024-02-21 19:46 ` Mike Maslenkin [this message]
2024-02-21 7:30 ` Nickle Wang via groups.io
2024-02-21 15:12 ` Chang, Abner via groups.io
2024-02-21 0:13 ` [edk2-devel] [PATCH 3/4] RedfishClientPkg/Bios: fix leak of GetPendingSettings URI Mike Maslenkin
2024-02-21 2:18 ` Chang, Abner via groups.io
2024-02-21 7:30 ` Nickle Wang via groups.io
2024-02-21 0:13 ` [edk2-devel] [PATCH 4/4] RedfishClientPkg: use Json value from a function argument Mike Maslenkin
2024-02-21 2:22 ` Chang, Abner via groups.io
2024-02-21 7:31 ` Nickle Wang via groups.io
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAL77WPAomOeu1SbCd+RcQtkKuSjYbiSeZg=V5AgpnnXHp6_eHg@mail.gmail.com' \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox