From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.27831.1669306713929222120 for ; Thu, 24 Nov 2022 08:18:34 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: pierre.gondois@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1C6DE106F; Thu, 24 Nov 2022 08:18:40 -0800 (PST) Received: from pierre123.nice.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3FE0D3F587; Thu, 24 Nov 2022 08:18:32 -0800 (PST) From: "PierreGondois" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Sami Mujawar , Jiewen Yao , Jian J Wang Subject: [PATCH v3 3/4] SecurityPkg/RngDxe: Conditionally install EFI_RNG_PROTOCOL Date: Thu, 24 Nov 2022 17:17:55 +0100 Message-Id: <20221124161756.216996-4-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124161756.216996-1-Pierre.Gondois@arm.com> References: <20221124161756.216996-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Pierre Gondois On Arm platforms, the number of available RNG algorithms is dynamically detected and can be 0 in the absence of FEAT_RNG and firmware TRNG. In this case, the EFI_RNG_PROTOCOL should not be installed to prevent from installing an empty protocol. Signed-off-by: Pierre Gondois --- .../RandomNumberGenerator/RngDxe/RngDxe.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c b/Security= Pkg/RandomNumberGenerator/RngDxe/RngDxe.c index 421abb52b8bf..d30cb7f47696 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c @@ -63,6 +63,18 @@ RngDriverEntry ( EFI_STATUS Status; EFI_HANDLE Handle; =20 + // + // Get the list of available algorithm. + // + Status =3D GetAvailableAlgorithms (); + if (EFI_ERROR (Status)) { + return Status; + } + + if (mAvailableAlgoArrayCount =3D=3D 0) { + return EFI_UNSUPPORTED; + } + // // Install UEFI RNG (Random Number Generator) Protocol // @@ -74,13 +86,10 @@ RngDriverEntry ( NULL ); if (EFI_ERROR (Status)) { - return Status; + FreeAvailableAlgorithms (); } =20 - // - // Get the list of available algorithm. - // - return GetAvailableAlgorithms (); + return Status; } =20 /** --=20 2.25.1