From nobody Mon Feb 9 14:38:03 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+112874+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+112874+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1703458787; cv=none; d=zohomail.com; s=zohoarc; b=hpOrFCfUynBP1Q923Um+cv89MUDHIq8/m0MVA6YQC3SPFGpXXhUDtWCCgYKcLWZqTbVHIfe5I7NGL2zWeAnPrC84SgsodcGkPNE7A0c6CmJp0gIH+IMJMzM+7PsqezWWWQBNp7tDXCdyhDlC+QmPcjocBxB5vVXzNl+XPpB4W90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703458787; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=y5BkAWqp+wxo59tjEKTRnGH3QYX2I25+d9Qx/tkCewM=; b=WVoz/8QZe8TdJ365Gn8kfv/L7zjnYDNdPoDqcY5xfI/WKR1BN6Qo/8+ovO4ekksq9cT914vNW64dtnG9pINZI9VwjXT8jYZ8TA3wgMpaaf3zP/VG9Uw1k8/rQgYSDC/AYcfvBH01U89/EfrjJQt8t2R48KPa4LDfqvyTfED7rxA= 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+112874+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 1703458787264184.80764633227864; Sun, 24 Dec 2023 14:59:47 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=uyLDn/tEGGc4V/WSH+yXdz/2S6vu0gy1RlYhmt1XUSM=; 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=1703458786; v=1; b=AahkpzX+Quh1mijhYm/Av6LVFVt55eur5EKkALJ6nGyzR60glEo5/7kRvqW/tHI2NUxNrCqt R9bbPs4Vfc1463VXMBJ+GNTc/l9PWdB1g6kkG4RCGP6YgvYRAmwpSqKKSeeWSe98yvP6E7qV5eB TF5Lpiu1GkKi9TUS+YFnX3cI= X-Received: by 127.0.0.2 with SMTP id EpwEYY1788612xpAkCfJiOqL; Sun, 24 Dec 2023 14:59:46 -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: O8EvDL0zAJNXFXircqePtcmlx1787277AA= 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-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1703458788882100059 Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D4625 Cc: Abner Chang Cc: Nickle Wang Cc: Igor Kulchytskyy Signed-off-by: Mike Maslenkin Reviewed-by: Abner Chang --- .../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) { AllocationSize =3D AsciiStrSize (RedfishLocation) * sizeof (CHA= R16); Information->Location =3D AllocatePool (AllocationSize); - AsciiStrToUnicodeStrS (RedfishLocation, Information->Location, Allocat= ionSize); - DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n", Inform= ation->Location)); + if (Information->Location !=3D NULL) { + AsciiStrToUnicodeStrS (RedfishLocation, Information->Location, Alloc= ationSize); + DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n", Info= rmation->Location)); + } else { + DEBUG (( + DEBUG_ERROR, + "%a: Can not allocate memory for Redfish service location: %a.\n", + __func__, + RedfishLocation + )); + } } =20 if (Uuid !=3D NULL) { AllocationSize =3D AsciiStrSize (Uuid) * sizeof (CHAR16); Information->Uuid =3D AllocatePool (AllocationSize); - AsciiStrToUnicodeStrS (Uuid, Information->Uuid, AllocationSize); - DEBUG ((DEBUG_MANAGEABILITY, "Service UUID: %s.\n", Information->Uuid)= ); + if (Information->Uuid !=3D NULL) { + AsciiStrToUnicodeStrS (Uuid, Information->Uuid, AllocationSize); + DEBUG ((DEBUG_MANAGEABILITY, "Service UUID: %s.\n", Information->Uui= d)); + } else { + DEBUG (( + DEBUG_ERROR, + "%a: Can not allocate memory for Service UUID: %a.\n", + __func__, + Uuid + )); + } } =20 if (Os !=3D NULL) { AllocationSize =3D AsciiStrSize (Os) * sizeof (CHAR16); Information->Os =3D AllocatePool (AllocationSize); - AsciiStrToUnicodeStrS (Os, Information->Os, AllocationSize); + if (Information->Os !=3D NULL) { + AsciiStrToUnicodeStrS (Os, Information->Os, AllocationSize); + } else { + DEBUG (( + DEBUG_ERROR, + "%a: Can not allocate memory for Redfish service OS: %a.\n", + __func__, + Os + )); + } } =20 if (OsVer !=3D NULL) { AllocationSize =3D AsciiStrSize (OsVer) * sizeof (CHAR16); Information->OsVersion =3D AllocatePool (AllocationSize); - AsciiStrToUnicodeStrS (OsVer, Information->OsVersion, AllocationSize); - DEBUG ((DEBUG_MANAGEABILITY, "Redfish service OS: %s, Version:%s.\n", = Information->Os, Information->OsVersion)); + if (Information->OsVersion !=3D NULL) { + AsciiStrToUnicodeStrS (OsVer, Information->OsVersion, AllocationSize= ); + DEBUG (( + DEBUG_MANAGEABILITY, + "Redfish service OS: %s, Version:%s.\n", + Information->Os, + Information->OsVersion + )); + } else { + DEBUG (( + DEBUG_ERROR, + "%a: Can not allocate memory for Redfish OS Version:%a.\n", + __func__, + OsVer + )); + } } =20 - if ((Product !=3D NULL) && (ProductVer !=3D NULL)) { + if (Product !=3D NULL) { AllocationSize =3D AsciiStrSize (Product) * sizeof (CHAR16); Information->Product =3D AllocatePool (AllocationSize); - AsciiStrToUnicodeStrS (Product, Information->Product, AllocationSize); + if (Information->Product !=3D NULL) { + AsciiStrToUnicodeStrS (Product, Information->Product, AllocationSize= ); + } else { + DEBUG (( + DEBUG_ERROR, + "%a: Can not allocate memory for Redfish service product: %a.\n", + __func__, + Product + )); + } + } + + if (ProductVer !=3D NULL) { AllocationSize =3D AsciiStrSize (ProductVer) * sizeof (CHAR16= ); Information->ProductVer =3D AllocatePool (AllocationSize); - AsciiStrToUnicodeStrS (ProductVer, Information->ProductVer, Allocation= Size); - DEBUG ((DEBUG_MANAGEABILITY, "Redfish service product: %s, Version:%s.= \n", Information->Product, Information->ProductVer)); + if (Information->ProductVer !=3D NULL) { + AsciiStrToUnicodeStrS (ProductVer, Information->ProductVer, Allocati= onSize); + DEBUG (( + DEBUG_MANAGEABILITY, + "Redfish service product: %s, Version:%s.\n", + Information->Product, + Information->ProductVer + )); + } else { + DEBUG (( + DEBUG_ERROR, + "%a: Can not allocate memory for Redfish service product Version: = %a.\n", + __func__, + ProductVer + )); + } } } =20 --=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 (#112874): https://edk2.groups.io/g/devel/message/112874 Mute This Topic: https://groups.io/mt/103354134/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-