public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
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] [edk2-redfish-client][PATCH V2] RedfishClientPkg/FeatureDriver:\r ComputerSystem_1_13_0 driver
Date: Fri, 26 Jan 2024 18:41:18 +0300	[thread overview]
Message-ID: <4907CA4D-C19B-4603-9EBF-1A102EFC215F@gmail.com> (raw)
In-Reply-To: <LV8PR12MB9452C96899BD760EB3F39D1FEA792@LV8PR12MB9452.namprd12.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 5094 bytes --]

BTW did you consider to remove this Private->Uri someday at all ?
I tried to remove it, but since it declared in a common header for all redfish client feature drivers
those changes was huge comparing to a small memory leak I tried to fix.
And now such pattern spreads into new feature drivers. 
In short: there is no need to cache this value in Private->Uri, but pass it as an argument down to stack in EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL implementation.
I think it just small design flaw. 

The code I'm talking about:
+  //
+  // Check and see if "@Redfish.Settings" exist or not.
+  //
+  ZeroMem (&PendingSettingResponse, sizeof (REDFISH_RESPONSE));
+  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;
+    ExpectedResponse = &PendingSettingResponse;
+  } else {
+    DEBUG ((REDFISH_DEBUG_TRACE, "%a: No @Redfish.Settings is found\n", __func__));
+    Private->Uri     = Uri;
+    ExpectedResponse = &Response;
+  }

In this pattern PendingSettingUri is leaked, since Private->Uri belongs to caller and never released.

But... in fact it is not true for Feature/Bios driver, and actually leaked resource is original Private->Uri string.

This is because these EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL function called by
HandleResource() function, which in turns called from here:
  //
  // Initialize collection path
  //
  Private->Uri = RedfishGetUri (ResourceUri);
  if (Private->Uri == NULL) {
    ASSERT (FALSE);
    FreePool (ResourceUri);
    return EFI_OUT_OF_RESOURCES;
  }

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

  FreePool (Private->Uri);


Too many "Private->Uri" with a different value. 

PS: Funny, just pay attention to the log trace above - %a used for Private->Uri. Probably it was one of the factors 
induced me to write previous message :)

Regards,
Mike.


> On 26. 1. 2024., at 17:13, Chang, Abner <Abner.Chang@amd.com> wrote:
> 
> [AMD Official Use Only - General]
> 
> It is no problem. 😊 Thank you Mike for looking into this patch.
> Abner
> 
>> -----Original Message-----
>> From: M M <mike.maslenkin@gmail.com>
>> Sent: Friday, January 26, 2024 10:11 PM
>> To: Chang, Abner <Abner.Chang@amd.com>
>> Cc: devel@edk2.groups.io; Nickle Wang <nicklew@nvidia.com>; Igor
>> Kulchytskyy <igork@ami.com>
>> Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH V2]
>> RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
>> 
>> Caution: This message originated from an External Source. Use proper caution
>> when opening attachments, clicking links, or responding.
>> 
>> 
>> You are right.
>> 
>> Sorry for the noise!
>> 
>> No problems here.
>> I mixed up with tags in my editor while looked into patch.
>> 
>> Regards,
>> Mike
>> 
>>> On 26. 1. 2024., at 17:03, Chang, Abner <Abner.Chang@amd.com> wrote:
>>> 
>>> [AMD Official Use Only - General]
>>> 
>>> Hi Mike,
>>> I can't identify the issue on %s as Private->Uri is defined as EFI_STRING, or I
>> miss something?
>>> 
>>> Thanks
>>> Abner
>>> 
>>>> -----Original Message-----
>>>> From: M M <mike.maslenkin@gmail.com>
>>>> Sent: Friday, January 26, 2024 9:55 PM
>>>> To: devel@edk2.groups.io; Nickle Wang <nicklew@nvidia.com>
>>>> Cc: Chang, Abner <Abner.Chang@amd.com>; Igor Kulchytskyy
>>>> <igork@ami.com>
>>>> Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH V2]
>>>> RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
>>>> 
>>>> Caution: This message originated from an External Source. Use proper
>> caution
>>>> when opening attachments, clicking links, or responding.
>>>> 
>>>> 
>>>> Hi Abner,
>>>> 
>>>>> On 26. 1. 2024., at 05:20, Nickle Wang via groups.io
>>>> <nicklew=nvidia.com@groups.io> wrote:
>>>>> 
>>>>> Hi Abner,
>>>>> 
>>>>> Same minor issue as 1_5_0. Please add "%a:" to below DEBUG call.
>>>>> 
>>>>>> +      DEBUG ((DEBUG_MANAGEABILITY, "  No platform Redfish
>>>> ConfigureLang
>>>>>> found for %s\n", __func__, Private->Uri));
>>>>> 
>>>>> Regards,
>>>>> Nickle
>>>> 
>>>> There are two issues in this string. The second one is incorrect  %s format
>> used
>>>> for Private->Uri.
>>>> This issue exists in V3 not only in the line mentioned above.
>>>> 
>>>> Regards,
>>>> Mike.
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114618): https://edk2.groups.io/g/devel/message/114618
Mute This Topic: https://groups.io/mt/103967446/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 14944 bytes --]

  reply	other threads:[~2024-01-26 15:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-26  1:00 [edk2-devel] [edk2-redfish-client][PATCH V2] RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver Chang, Abner via groups.io
2024-01-26  2:20 ` Nickle Wang via groups.io
2024-01-26  2:32   ` Chang, Abner via groups.io
2024-01-26 13:55   ` Mike Maslenkin
2024-01-26 14:03     ` Chang, Abner via groups.io
2024-01-26 14:11       ` Mike Maslenkin
2024-01-26 14:13         ` Chang, Abner via groups.io
2024-01-26 15:41           ` Mike Maslenkin [this message]
2024-01-30  7:58             ` 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=4907CA4D-C19B-4603-9EBF-1A102EFC215F@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