From nobody Mon Feb 9 08:56:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109220+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109220+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1696024765; cv=none; d=zohomail.com; s=zohoarc; b=PSnaUDPHRUOSEcjPZU57T+U/LwufpakO8ysoS2iGEDeulJyfJ8VZcPcUoP9gM7hzz4gn7lm8YD5vCZI5OvYRX+ce46GXSfiuHRVo4oiMEEt7liyhgLRirTlB2TGgb6rFg5J711Pkrmtr9syrrOFXPhf7pF8JipRChnur0y6B6jo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696024765; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=4DqicQDorf8Bbi4k9pOQDYJxY+dXK2Zz8twAOiVtZHk=; b=hZ7ZRloqFHDK2TX+QZCKDq5X8Aa7VpxdqefvqWsX1FjUjntnC5UaLkthsj/ylCy9kHzOiD6exdpbVXcHzLeZAT8V9zsyRJQzpZIBVNFAnjmUNrgcoVBz01S87OlDkQ/8WJJZhTeHazTn3tHdPQHxdXzVhHIEQE6dfFU04HY4Pxg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109220+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1696024765920933.5529632906912; Fri, 29 Sep 2023 14:59:25 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=EXzl7ylqunQyNthINMialDH+UOUBp9s6kCJoX/aC5mI=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1696024765; v=1; b=DK12q1B8MZfImpEBQHXSYXt5Mv1ZAXCuO6ETmdv5Z725boZaKrfDel18pmeuYmmACSDhdetw kPnJ8ZTXkGrUwE78AobYo0WAvAE7RK8e5NaMbEmyD8g+UWqloljqdT+xx43BpaZi1IrCCgeKiKi V9A4UATaFQufZDeAHYBSK6Pk= X-Received: by 127.0.0.2 with SMTP id o0QiYY1788612xeJFv9JSdEQ; Fri, 29 Sep 2023 14:59:25 -0700 X-Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) by mx.groups.io with SMTP id smtpd.web10.30358.1696024764648062168 for ; Fri, 29 Sep 2023 14:59:25 -0700 X-Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2c135cf2459so217796391fa.0 for ; Fri, 29 Sep 2023 14:59:24 -0700 (PDT) X-Gm-Message-State: p3e319du4XSH94LeDPxX8WNEx1787277AA= X-Google-Smtp-Source: AGHT+IE0RXCD+sb4eXMCxoNF/TkspElQ9WkUIowRxDq49tOECuS3f82TACDKE74+bE3UrQ/z/5x0Xw== X-Received: by 2002:a2e:a41a:0:b0:2c0:21b6:e80c with SMTP id p26-20020a2ea41a000000b002c021b6e80cmr5242466ljn.35.1696024762700; Fri, 29 Sep 2023 14:59:22 -0700 (PDT) X-Received: from localhost.localdomain ([185.9.78.108]) by smtp.gmail.com with ESMTPSA id y24-20020a2ebb98000000b002bfe8537f37sm890178lje.33.2023.09.29.14.59.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 29 Sep 2023 14:59:22 -0700 (PDT) From: "Mike Maslenkin" To: devel@edk2.groups.io Cc: abner.chang@amd.com, nicklew@nvidia.com, igork@ami.com, Mike Maslenkin Subject: [edk2-devel] [PATCH 4/9] RedfishClientPkg: RedfishFeatureUtilityLib: fix memory leaks Date: Sat, 30 Sep 2023 00:59:10 +0300 Message-Id: <20230929215915.46616-5-mike.maslenkin@gmail.com> In-Reply-To: <20230929215915.46616-1-mike.maslenkin@gmail.com> References: <20230929215915.46616-1-mike.maslenkin@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mike.maslenkin@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1696024767261100017 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mike Maslenkin Reviewed-by: Abner Chang --- .../RedfishFeatureUtilityLib.c | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatu= reUtilityLib.c b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishF= eatureUtilityLib.c index 35e342c817b7..8fa1dc2c3535 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.c +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.c @@ -515,6 +515,7 @@ ApplyFeatureSettingsVagueType ( Status =3D UnicodeStrToAsciiStrS (ConfigureLang, ConfigureLangAscii, Str= Len (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; } =20 @@ -1972,6 +1973,7 @@ RedfishGetUri ( // if (*Target =3D=3D '\0') { DEBUG ((DEBUG_ERROR, "%a, invalid format: %s\n", __func__, ConfigLan= g)); + FreePool (ResultStr); return NULL; } =20 @@ -1983,6 +1985,7 @@ RedfishGetUri ( TempStrSize =3D (ConfigLangLen - RemainingLen + 1) * sizeof (CHAR16); TempStr =3D AllocateCopyPool (TempStrSize, Head); if (TempStr =3D=3D NULL) { + FreePool (ResultStr); return NULL; } =20 @@ -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; } =20 @@ -2102,10 +2107,14 @@ GetConfigureLang ( =20 Status =3D AsciiStrToUnicodeStrS (Uri, UnicodeUri, StringSize); if (EFI_ERROR (Status)) { + FreePool (UnicodeUri); return NULL; } =20 ConfigLang =3D RedfishGetConfigLanguage (UnicodeUri); + + FreePool (UnicodeUri); + if (ConfigLang =3D=3D NULL) { return NULL; } @@ -2117,11 +2126,14 @@ GetConfigureLang ( StringSize =3D StrSize (ConfigLang) + ((AsciiStrLen (PropertyName) + 1) = * sizeof (CHAR16)); ResultStr =3D AllocatePool (StringSize); if (ResultStr =3D=3D NULL) { + FreePool (ConfigLang); return NULL; } =20 UnicodeSPrint (ResultStr, StringSize, L"%s/%a", ConfigLang, PropertyName= ); =20 + FreePool (ConfigLang); + return ResultStr; } =20 @@ -2296,9 +2308,12 @@ GetPropertyStringValue ( Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLang= Buffer, &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; } =20 + FreePool (ConfigureLangBuffer); + if (RedfishValue.Type !=3D 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 =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLang= Buffer, &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; } =20 + FreePool (ConfigureLangBuffer); + if (RedfishValue.Type !=3D RedfishValueTypeInteger) { DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not numeric type\n", __fun= c__, Schema, Version, ConfigureLang)); return NULL; @@ -2416,9 +2434,12 @@ GetPropertyBooleanValue ( Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLang= Buffer, &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; } =20 + FreePool (ConfigureLangBuffer); + if (RedfishValue.Type !=3D RedfishValueTypeBoolean) { DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not boolean type\n", __fun= c__, Schema, Version, ConfigureLang)); return NULL; @@ -2517,9 +2538,12 @@ GetPropertyStringArrayValue ( Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLang= Buffer, &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; } =20 + FreePool (ConfigureLangBuffer); + if (RedfishValue.Type !=3D 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 =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLang= Buffer, &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; } =20 + FreePool (ConfigureLangBuffer); + if (RedfishValue.Type !=3D 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 =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLang= Buffer, &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; } =20 + FreePool (ConfigureLangBuffer); + if (RedfishValue.Type !=3D RedfishValueTypeBooleanArray) { DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not string array type\n", = __func__, Schema, Version, ConfigureLang)); return NULL; --=20 2.32.0 (Apple Git-132) -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109220): https://edk2.groups.io/g/devel/message/109220 Mute This Topic: https://groups.io/mt/101667463/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-