[edk2-devel] [PATCH 4/9] RedfishClientPkg: RedfishFeatureUtilityLib: fix memory leaks

Chang, Abner via groups.io abner.chang=amd.com at groups.io
Mon Oct 2 02:25:03 UTC 2023


[AMD Official Use Only - General]

Reviewed-by: Abner Chang <Abner.Chang at amd.com>

> -----Original Message-----
> From: Mike Maslenkin <mike.maslenkin at gmail.com>
> Sent: Saturday, September 30, 2023 5:59 AM
> To: devel at edk2.groups.io
> Cc: Chang, Abner <Abner.Chang at amd.com>; nicklew at nvidia.com;
> igork at ami.com; Mike Maslenkin <mike.maslenkin at gmail.com>
> Subject: [PATCH 4/9] RedfishClientPkg: RedfishFeatureUtilityLib: fix memory
> leaks
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Signed-off-by: Mike Maslenkin <mike.maslenkin at 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 (#109245): https://edk2.groups.io/g/devel/message/109245
Mute This Topic: https://groups.io/mt/101667463/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list