From: "Mike Maslenkin" <mike.maslenkin@gmail.com>
To: devel@edk2.groups.io
Cc: abner.chang@amd.com, nicklew@nvidia.com, igork@ami.com,
Mike Maslenkin <mike.maslenkin@gmail.com>
Subject: [edk2-devel] [edk2-redfish-client][PATCH v2 04/11] RedfishClientPkg: RedfishFeatureUtilityLib: fix memory leaks
Date: Fri, 27 Oct 2023 02:53:47 +0300 [thread overview]
Message-ID: <20231026235354.67625-5-mike.maslenkin@gmail.com> (raw)
In-Reply-To: <20231026235354.67625-1-mike.maslenkin@gmail.com>
Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
---
.../RedfishFeatureUtilityLib.c | 30 +++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
index 35e342c817b7..8fa1dc2c3535 100644
--- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
+++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
@@ -515,6 +515,7 @@ ApplyFeatureSettingsVagueType (
Status = UnicodeStrToAsciiStrS (ConfigureLang, ConfigureLangAscii, StrLen (ConfigureLang) + 1);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, Convert the configureLang of vague key of %a.%a %s failed: %r\n", __func__, Schema, Version, ConfigureLang, Status));
+ FreePool (ConfigureLangAscii);
return Status;
}
@@ -1972,6 +1973,7 @@ RedfishGetUri (
//
if (*Target == '\0') {
DEBUG ((DEBUG_ERROR, "%a, invalid format: %s\n", __func__, ConfigLang));
+ FreePool (ResultStr);
return NULL;
}
@@ -1983,6 +1985,7 @@ RedfishGetUri (
TempStrSize = (ConfigLangLen - RemainingLen + 1) * sizeof (CHAR16);
TempStr = AllocateCopyPool (TempStrSize, Head);
if (TempStr == NULL) {
+ FreePool (ResultStr);
return NULL;
}
@@ -1996,6 +1999,8 @@ RedfishGetUri (
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, Can not find: %s\n", __func__, TempStr));
+ FreePool (ResultStr);
+ FreePool (TempStr);
return NULL;
}
@@ -2102,10 +2107,14 @@ GetConfigureLang (
Status = AsciiStrToUnicodeStrS (Uri, UnicodeUri, StringSize);
if (EFI_ERROR (Status)) {
+ FreePool (UnicodeUri);
return NULL;
}
ConfigLang = RedfishGetConfigLanguage (UnicodeUri);
+
+ FreePool (UnicodeUri);
+
if (ConfigLang == NULL) {
return NULL;
}
@@ -2117,11 +2126,14 @@ GetConfigureLang (
StringSize = StrSize (ConfigLang) + ((AsciiStrLen (PropertyName) + 1) * sizeof (CHAR16));
ResultStr = AllocatePool (StringSize);
if (ResultStr == NULL) {
+ FreePool (ConfigLang);
return NULL;
}
UnicodeSPrint (ResultStr, StringSize, L"%s/%a", ConfigLang, PropertyName);
+ FreePool (ConfigLang);
+
return ResultStr;
}
@@ -2296,9 +2308,12 @@ GetPropertyStringValue (
Status = RedfishPlatformConfigGetValue (Schema, Version, ConfigureLangBuffer, &RedfishValue);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed: %r\n", __func__, Schema, Version, ConfigureLangBuffer, Status));
+ FreePool (ConfigureLangBuffer);
return NULL;
}
+ FreePool (ConfigureLangBuffer);
+
if (RedfishValue.Type != RedfishValueTypeString) {
DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not string type\n", __func__, Schema, Version, ConfigureLang));
return NULL;
@@ -2354,9 +2369,12 @@ GetPropertyNumericValue (
Status = RedfishPlatformConfigGetValue (Schema, Version, ConfigureLangBuffer, &RedfishValue);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed: %r\n", __func__, Schema, Version, ConfigureLangBuffer, Status));
+ FreePool (ConfigureLangBuffer);
return NULL;
}
+ FreePool (ConfigureLangBuffer);
+
if (RedfishValue.Type != RedfishValueTypeInteger) {
DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not numeric type\n", __func__, Schema, Version, ConfigureLang));
return NULL;
@@ -2416,9 +2434,12 @@ GetPropertyBooleanValue (
Status = RedfishPlatformConfigGetValue (Schema, Version, ConfigureLangBuffer, &RedfishValue);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed: %r\n", __func__, Schema, Version, ConfigureLangBuffer, Status));
+ FreePool (ConfigureLangBuffer);
return NULL;
}
+ FreePool (ConfigureLangBuffer);
+
if (RedfishValue.Type != RedfishValueTypeBoolean) {
DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not boolean type\n", __func__, Schema, Version, ConfigureLang));
return NULL;
@@ -2517,9 +2538,12 @@ GetPropertyStringArrayValue (
Status = RedfishPlatformConfigGetValue (Schema, Version, ConfigureLangBuffer, &RedfishValue);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed: %r\n", __func__, Schema, Version, ConfigureLangBuffer, Status));
+ FreePool (ConfigureLangBuffer);
return NULL;
}
+ FreePool (ConfigureLangBuffer);
+
if (RedfishValue.Type != RedfishValueTypeStringArray) {
DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not string array type\n", __func__, Schema, Version, ConfigureLang));
return NULL;
@@ -2588,9 +2612,12 @@ GetPropertyNumericArrayValue (
Status = RedfishPlatformConfigGetValue (Schema, Version, ConfigureLangBuffer, &RedfishValue);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed: %r\n", __func__, Schema, Version, ConfigureLangBuffer, Status));
+ FreePool (ConfigureLangBuffer);
return NULL;
}
+ FreePool (ConfigureLangBuffer);
+
if (RedfishValue.Type != RedfishValueTypeIntegerArray) {
DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not string array type\n", __func__, Schema, Version, ConfigureLang));
return NULL;
@@ -2659,9 +2686,12 @@ GetPropertyBooleanArrayValue (
Status = RedfishPlatformConfigGetValue (Schema, Version, ConfigureLangBuffer, &RedfishValue);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed: %r\n", __func__, Schema, Version, ConfigureLangBuffer, Status));
+ FreePool (ConfigureLangBuffer);
return NULL;
}
+ FreePool (ConfigureLangBuffer);
+
if (RedfishValue.Type != RedfishValueTypeBooleanArray) {
DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not string array type\n", __func__, Schema, Version, ConfigureLang));
return NULL;
--
2.32.0 (Apple Git-132)
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110149): https://edk2.groups.io/g/devel/message/110149
Mute This Topic: https://groups.io/mt/102211773/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:[~2023-10-26 23:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-26 23:53 [edk2-devel] [edk2-redfish-client][PATCH v2 0/11] RedfishClientPkg: various minor fixes Mike Maslenkin
2023-10-26 23:53 ` [edk2-devel] [edk2-redfish-client][PATCH v2 01/11] RedfishClientPkg: fix format used for output __func__ Mike Maslenkin
2023-10-26 23:53 ` [edk2-devel] [edk2-redfish-client][PATCH v2 02/11] RedfishClientPkg: fix DEBUG macro arguments Mike Maslenkin
2023-10-26 23:53 ` [edk2-devel] [edk2-redfish-client][PATCH v2 03/11] RedfishLib: remove redudant zeroing Mike Maslenkin
2023-10-26 23:53 ` Mike Maslenkin [this message]
2023-10-26 23:53 ` [edk2-devel] [edk2-redfish-client][PATCH v2 05/11] RedfishClientPkg: reduce identation level by adding early return Mike Maslenkin
2023-10-26 23:53 ` [edk2-devel] [edk2-redfish-client][PATCH v2 06/11] RedfishClientPkg: fix memory leaks while applying feature settings Mike Maslenkin
2023-10-26 23:53 ` [edk2-devel] [edk2-redfish-client][PATCH v2 07/11] RedfishClientPkg: fix memory leak Mike Maslenkin
2023-10-26 23:53 ` [edk2-devel] [edk2-redfish-client][PATCH v2 08/11] RedfishClientPkg: fix pragma pack usage Mike Maslenkin
2023-10-26 23:53 ` [edk2-devel] [edk2-redfish-client][PATCH v2 09/11] RedfishClientPkg: fix StrnCpyS arguments Mike Maslenkin
2023-10-27 2:34 ` Chang, Abner via groups.io
2023-10-26 23:53 ` [edk2-devel] [edk2-redfish-client][PATCH v2 10/11] RedfishFeatureCoreDxe: replace __FUNCTION__ with __func__ Mike Maslenkin
2023-10-26 23:53 ` [edk2-devel] [edk2-redfish-client][PATCH v2 11/11] RedfishFeatureCoreDxe: add check for memory allocation failure Mike Maslenkin
2023-10-27 2:35 ` Chang, Abner via groups.io
2023-10-30 7:21 ` [edk2-devel] [edk2-redfish-client][PATCH v2 0/11] RedfishClientPkg: various minor fixes 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=20231026235354.67625-5-mike.maslenkin@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