From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 87947D80591 for ; Sun, 24 Dec 2023 22:59:48 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=zPpBxsTplX9u9BxhFmeXGTrbhlhGUlFrUOZOrjCpFV0=; 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=1703458787; v=1; b=N2bk365wMFiKomsu9ZURC0bq6IjARdwIVZWPbGL5vYaStE6vqXv//LUYQ4auIvy1vjmmishv 3xitTZg3byuc5DsESoSZkVEln/kP3SaT5+2uK7MjGnJk/XGtzwjytMNEyzsQrRn5j3wCouLeTTd VNktd1sBJviNlIrd8T/QeRaQ= X-Received: by 127.0.0.2 with SMTP id ZfESYY7687511x0L2iuAMjVK; Sun, 24 Dec 2023 14:59:47 -0800 X-Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by mx.groups.io with SMTP id smtpd.web10.35950.1703458785240365454 for ; Sun, 24 Dec 2023 14:59:45 -0800 X-Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-50e6ee5b7ffso1593865e87.3 for ; Sun, 24 Dec 2023 14:59:44 -0800 (PST) X-Gm-Message-State: 1JfdomrNMEdONHDhGXN1unjCx7686176AA= X-Google-Smtp-Source: AGHT+IErWE6XMM23XUoGRJTBsJw1x3UNktwCT0vrFv35T1biSqBdRUU8Ey0eE4YddaDPbEzBHhrXOA== X-Received: by 2002:ac2:57c5:0:b0:50e:7d19:1474 with SMTP id k5-20020ac257c5000000b0050e7d191474mr51369lfo.36.1703458783402; Sun, 24 Dec 2023 14:59:43 -0800 (PST) X-Received: from localhost.localdomain ([79.164.221.98]) by smtp.gmail.com with ESMTPSA id be44-20020a056512252c00b0050e78f5178asm326596lfb.262.2023.12.24.14.59.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 24 Dec 2023 14:59:43 -0800 (PST) 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 v3 15/16] RedfishDiscoverDxe: handle memory allocation error conditions. Date: Mon, 25 Dec 2023 01:59:26 +0300 Message-Id: <20231224225927.9119-16-mike.maslenkin@gmail.com> In-Reply-To: <20231224225927.9119-1-mike.maslenkin@gmail.com> References: <20231224225927.9119-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-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=N2bk365w; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none) REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D4625 Cc: Abner Chang Cc: Nickle Wang Cc: Igor Kulchytskyy Signed-off-by: Mike Maslenkin --- .../RedfishDiscoverDxe/RedfishDiscoverDxe.c | 89 ++++++++++++++++--- 1 file changed, 78 insertions(+), 11 deletions(-) diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPk= g/RedfishDiscoverDxe/RedfishDiscoverDxe.c index bbd1f4b86400..1022ab090df8 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c @@ -791,38 +791,105 @@ InitInformationData ( if (RedfishLocation !=3D NULL) {=0D AllocationSize =3D AsciiStrSize (RedfishLocation) * sizeof (CHA= R16);=0D Information->Location =3D AllocatePool (AllocationSize);=0D - AsciiStrToUnicodeStrS (RedfishLocation, Information->Location, Allocat= ionSize);=0D - DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n", Inform= ation->Location));=0D + if (Information->Location !=3D NULL) {=0D + AsciiStrToUnicodeStrS (RedfishLocation, Information->Location, Alloc= ationSize);=0D + DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n", Info= rmation->Location));=0D + } else {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "%a: Can not allocate memory for Redfish service location: %a.\n",= =0D + __func__,=0D + RedfishLocation=0D + ));=0D + }=0D }=0D =0D if (Uuid !=3D NULL) {=0D AllocationSize =3D AsciiStrSize (Uuid) * sizeof (CHAR16);=0D Information->Uuid =3D AllocatePool (AllocationSize);=0D - AsciiStrToUnicodeStrS (Uuid, Information->Uuid, AllocationSize);=0D - DEBUG ((DEBUG_MANAGEABILITY, "Service UUID: %s.\n", Information->Uuid)= );=0D + if (Information->Uuid !=3D NULL) {=0D + AsciiStrToUnicodeStrS (Uuid, Information->Uuid, AllocationSize);=0D + DEBUG ((DEBUG_MANAGEABILITY, "Service UUID: %s.\n", Information->Uui= d));=0D + } else {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "%a: Can not allocate memory for Service UUID: %a.\n",=0D + __func__,=0D + Uuid=0D + ));=0D + }=0D }=0D =0D if (Os !=3D NULL) {=0D AllocationSize =3D AsciiStrSize (Os) * sizeof (CHAR16);=0D Information->Os =3D AllocatePool (AllocationSize);=0D - AsciiStrToUnicodeStrS (Os, Information->Os, AllocationSize);=0D + if (Information->Os !=3D NULL) {=0D + AsciiStrToUnicodeStrS (Os, Information->Os, AllocationSize);=0D + } else {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "%a: Can not allocate memory for Redfish service OS: %a.\n",=0D + __func__,=0D + Os=0D + ));=0D + }=0D }=0D =0D if (OsVer !=3D NULL) {=0D AllocationSize =3D AsciiStrSize (OsVer) * sizeof (CHAR16);=0D Information->OsVersion =3D AllocatePool (AllocationSize);=0D - AsciiStrToUnicodeStrS (OsVer, Information->OsVersion, AllocationSize);= =0D - DEBUG ((DEBUG_MANAGEABILITY, "Redfish service OS: %s, Version:%s.\n", = Information->Os, Information->OsVersion));=0D + if (Information->OsVersion !=3D NULL) {=0D + AsciiStrToUnicodeStrS (OsVer, Information->OsVersion, AllocationSize= );=0D + DEBUG ((=0D + DEBUG_MANAGEABILITY,=0D + "Redfish service OS: %s, Version:%s.\n",=0D + Information->Os,=0D + Information->OsVersion=0D + ));=0D + } else {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "%a: Can not allocate memory for Redfish OS Version:%a.\n",=0D + __func__,=0D + OsVer=0D + ));=0D + }=0D }=0D =0D - if ((Product !=3D NULL) && (ProductVer !=3D NULL)) {=0D + if (Product !=3D NULL) {=0D AllocationSize =3D AsciiStrSize (Product) * sizeof (CHAR16);=0D Information->Product =3D AllocatePool (AllocationSize);=0D - AsciiStrToUnicodeStrS (Product, Information->Product, AllocationSize);= =0D + if (Information->Product !=3D NULL) {=0D + AsciiStrToUnicodeStrS (Product, Information->Product, AllocationSize= );=0D + } else {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "%a: Can not allocate memory for Redfish service product: %a.\n",= =0D + __func__,=0D + Product=0D + ));=0D + }=0D + }=0D +=0D + if (ProductVer !=3D NULL) {=0D AllocationSize =3D AsciiStrSize (ProductVer) * sizeof (CHAR16= );=0D Information->ProductVer =3D AllocatePool (AllocationSize);=0D - AsciiStrToUnicodeStrS (ProductVer, Information->ProductVer, Allocation= Size);=0D - DEBUG ((DEBUG_MANAGEABILITY, "Redfish service product: %s, Version:%s.= \n", Information->Product, Information->ProductVer));=0D + if (Information->ProductVer !=3D NULL) {=0D + AsciiStrToUnicodeStrS (ProductVer, Information->ProductVer, Allocati= onSize);=0D + DEBUG ((=0D + DEBUG_MANAGEABILITY,=0D + "Redfish service product: %s, Version:%s.\n",=0D + Information->Product,=0D + Information->ProductVer=0D + ));=0D + } else {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "%a: Can not allocate memory for Redfish service product Version: = %a.\n",=0D + __func__,=0D + ProductVer=0D + ));=0D + }=0D }=0D }=0D =0D --=20 2.32.0 (Apple Git-132) -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112874): https://edk2.groups.io/g/devel/message/112874 Mute This Topic: https://groups.io/mt/103354134/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-