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 <[email protected]>
---
 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

Reply via email to