public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Nickle Wang via groups.io" <nicklew=nvidia.com@groups.io>
To: M M <mike.maslenkin@gmail.com>, "Chang, Abner" <Abner.Chang@amd.com>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	Igor Kulchytskyy <igork@ami.com>
Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH V2] RedfishClientPkg/FeatureDriver:\r ComputerSystem_1_13_0 driver
Date: Tue, 30 Jan 2024 07:58:27 +0000	[thread overview]
Message-ID: <PH8PR12MB70257E4CC1EDFB0E9C30E2C4D97D2@PH8PR12MB7025.namprd12.prod.outlook.com> (raw)
In-Reply-To: <4907CA4D-C19B-4603-9EBF-1A102EFC215F@gmail.com>

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

Hi Mike,

How about we add code to release “PendingSettingUri” at the end of RedfishResourceConsumeResource(). I think this would help to address memory leak issue. And we keep “Private->Uri” to be just the reference to “Uri” from caller and we don’t release “Private->Uri”. Caller always has responsibility to release memory it allocated.

Then, I like to modify below code to match my logic above:

  //
  // Initialize collection path
  //
  CollectionUri = RedfishGetUri (ResourceUri);
  if (CollectionUri == NULL) {
    ASSERT (FALSE);
    FreePool (ResourceUri);
    return EFI_OUT_OF_RESOURCES;
  }

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

  FreePool (CollectionUri);


In this way, we don’ have huge changes to fix memory leak issue as you mentioned. (removing Private->Uri) Please let me know if this makes sense to you or not.

Thanks,
Nickle

From: M M <mike.maslenkin@gmail.com>
Sent: Friday, January 26, 2024 11:41 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

External email: Use caution opening links or attachments

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<mailto: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<mailto:mike.maslenkin@gmail.com>>
Sent: Friday, January 26, 2024 10:11 PM
To: Chang, Abner <Abner.Chang@amd.com<mailto:Abner.Chang@amd.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>; Igor
Kulchytskyy <igork@ami.com<mailto: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<mailto: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<mailto:mike.maslenkin@gmail.com>>
Sent: Friday, January 26, 2024 9:55 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Cc: Chang, Abner <Abner.Chang@amd.com<mailto:Abner.Chang@amd.com>>; Igor Kulchytskyy
<igork@ami.com<mailto: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<http://groups.io/>
<nicklew=nvidia.com@groups.io<mailto: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 (#114765): https://edk2.groups.io/g/devel/message/114765
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: 23610 bytes --]

      reply	other threads:[~2024-01-30  7:58 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
2024-01-30  7:58             ` Nickle Wang via groups.io [this message]

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=PH8PR12MB70257E4CC1EDFB0E9C30E2C4D97D2@PH8PR12MB7025.namprd12.prod.outlook.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