U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] efi_loader: fix GetRng() implementation
@ 2026-08-20 13:07 Heinrich Schuchardt
  2026-08-20 13:07 ` [PATCH 1/2] efi_loader: in platform_get_rng_device() use EFI_PRINT() Heinrich Schuchardt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2026-08-20 13:07 UTC (permalink / raw)
  To: Ilias Apalodimas; +Cc: Tom Rini, u-boot, Heinrich Schuchardt

Use EFI_PRINT() instead of debug() to correctly indent the message.

The return value of platform_get_rng_device() is efi_status_t.
It does not fit into an integer variable ret. Use variable status.

We already write a debug message in platform_get_rng_device().
We should not repeat ourselves.

The RNG device was available when registering the protocol. When it is no
longer available in GetRng(), this is a device error and not an unsupported
algorithm. Use EFI_DEVICE_ERROR returned by platform_get_rng_device() as
return value of GetRng().

Heinrich Schuchardt (2):
  efi_loader: in platform_get_rng_device() use EFI_PRINT()
  efi_loader: consider type of platform_get_rng_device() return value

 lib/efi_loader/efi_rng.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] efi_loader: in platform_get_rng_device() use EFI_PRINT()
  2026-08-20 13:07 [PATCH 0/2] efi_loader: fix GetRng() implementation Heinrich Schuchardt
@ 2026-08-20 13:07 ` Heinrich Schuchardt
  2026-08-20 13:07 ` [PATCH 2/2] efi_loader: consider type of platform_get_rng_device() return value Heinrich Schuchardt
  2026-08-21  0:44 ` [PATCH 0/2] efi_loader: fix GetRng() implementation dmukhin
  2 siblings, 0 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2026-08-20 13:07 UTC (permalink / raw)
  To: Ilias Apalodimas; +Cc: Tom Rini, u-boot, Heinrich Schuchardt

Use EFI_PRINT() instead of debug() to correctly indent the message.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 lib/efi_loader/efi_rng.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_rng.c b/lib/efi_loader/efi_rng.c
index 7810b4e47ea..9c5a60ea963 100644
--- a/lib/efi_loader/efi_rng.c
+++ b/lib/efi_loader/efi_rng.c
@@ -31,7 +31,7 @@ __weak efi_status_t platform_get_rng_device(struct udevice **dev)
 
 	ret = uclass_get_device(UCLASS_RNG, 0, &devp);
 	if (ret) {
-		debug("Unable to get rng device\n");
+		EFI_PRINT("Unable to get rng device\n");
 		return EFI_DEVICE_ERROR;
 	}
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] efi_loader: consider type of platform_get_rng_device() return value
  2026-08-20 13:07 [PATCH 0/2] efi_loader: fix GetRng() implementation Heinrich Schuchardt
  2026-08-20 13:07 ` [PATCH 1/2] efi_loader: in platform_get_rng_device() use EFI_PRINT() Heinrich Schuchardt
@ 2026-08-20 13:07 ` Heinrich Schuchardt
  2026-08-21  0:44 ` [PATCH 0/2] efi_loader: fix GetRng() implementation dmukhin
  2 siblings, 0 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2026-08-20 13:07 UTC (permalink / raw)
  To: Ilias Apalodimas; +Cc: Tom Rini, u-boot, Heinrich Schuchardt

The return value of platform_get_rng_device() is efi_status_t.
It does not fit into an integer variable ret. Use variable status.

We already write a debug message in platform_get_rng_device().
We should not repeat ourselves.

The RNG device was available when registering the protocol. When it is no
longer available in GetRng(), this is a device error and not an unsupported
algorithm. Use EFI_DEVICE_ERROR returned by platform_get_rng_device() as
return value of GetRng().

Addresses-Coverity-ID: 532068 Overflowed constant
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 lib/efi_loader/efi_rng.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/lib/efi_loader/efi_rng.c b/lib/efi_loader/efi_rng.c
index 9c5a60ea963..6c1c5f0be60 100644
--- a/lib/efi_loader/efi_rng.c
+++ b/lib/efi_loader/efi_rng.c
@@ -105,7 +105,7 @@ static efi_status_t EFIAPI getrng(struct efi_rng_protocol *this,
 				  uint8_t *rng_value)
 {
 	int ret;
-	efi_status_t status = EFI_SUCCESS;
+	efi_status_t status;
 	struct udevice *dev;
 	const efi_guid_t rng_raw_guid = EFI_RNG_ALGORITHM_RAW;
 
@@ -125,12 +125,9 @@ static efi_status_t EFIAPI getrng(struct efi_rng_protocol *this,
 		}
 	}
 
-	ret = platform_get_rng_device(&dev);
-	if (ret != EFI_SUCCESS) {
-		EFI_PRINT("Rng device not found\n");
-		status = EFI_UNSUPPORTED;
+	status = platform_get_rng_device(&dev);
+	if (status != EFI_SUCCESS)
 		goto back;
-	}
 
 	ret = dm_rng_read(dev, rng_value, rng_value_length);
 	if (ret < 0) {
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] efi_loader: fix GetRng() implementation
  2026-08-20 13:07 [PATCH 0/2] efi_loader: fix GetRng() implementation Heinrich Schuchardt
  2026-08-20 13:07 ` [PATCH 1/2] efi_loader: in platform_get_rng_device() use EFI_PRINT() Heinrich Schuchardt
  2026-08-20 13:07 ` [PATCH 2/2] efi_loader: consider type of platform_get_rng_device() return value Heinrich Schuchardt
@ 2026-08-21  0:44 ` dmukhin
  2 siblings, 0 replies; 4+ messages in thread
From: dmukhin @ 2026-08-21  0:44 UTC (permalink / raw)
  To: Heinrich Schuchardt; +Cc: Ilias Apalodimas, Tom Rini, u-boot

On Thu, Aug 20, 2026 at 03:07:44PM +0200, Heinrich Schuchardt wrote:
> Use EFI_PRINT() instead of debug() to correctly indent the message.
> 
> The return value of platform_get_rng_device() is efi_status_t.
> It does not fit into an integer variable ret. Use variable status.
> 
> We already write a debug message in platform_get_rng_device().
> We should not repeat ourselves.
> 
> The RNG device was available when registering the protocol. When it is no
> longer available in GetRng(), this is a device error and not an unsupported
> algorithm. Use EFI_DEVICE_ERROR returned by platform_get_rng_device() as
> return value of GetRng().
> 
> Heinrich Schuchardt (2):
>   efi_loader: in platform_get_rng_device() use EFI_PRINT()
>   efi_loader: consider type of platform_get_rng_device() return value

Please consider

Reviewed-by: Denis Mukhin <dmukhin@ford.com> 

for the series.

> 
>  lib/efi_loader/efi_rng.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> -- 
> 2.53.0
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-21  0:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-20 13:07 [PATCH 0/2] efi_loader: fix GetRng() implementation Heinrich Schuchardt
2026-08-20 13:07 ` [PATCH 1/2] efi_loader: in platform_get_rng_device() use EFI_PRINT() Heinrich Schuchardt
2026-08-20 13:07 ` [PATCH 2/2] efi_loader: consider type of platform_get_rng_device() return value Heinrich Schuchardt
2026-08-21  0:44 ` [PATCH 0/2] efi_loader: fix GetRng() implementation dmukhin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox