The return value of platform_get_rng_device() is efi_status_t. It does not fit into an integer variable ret. Use variable status.
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]> --- v2: keep the EFI_PRINT() debug message --- lib/efi_loader/efi_rng.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/efi_loader/efi_rng.c b/lib/efi_loader/efi_rng.c index e920eec9d7b..3a831e2232b 100644 --- a/lib/efi_loader/efi_rng.c +++ b/lib/efi_loader/efi_rng.c @@ -103,7 +103,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; @@ -123,10 +123,9 @@ static efi_status_t EFIAPI getrng(struct efi_rng_protocol *this, } } - ret = platform_get_rng_device(&dev); - if (ret != EFI_SUCCESS) { + status = platform_get_rng_device(&dev); + if (status != EFI_SUCCESS) { EFI_PRINT("Rng device not found\n"); - status = EFI_UNSUPPORTED; goto back; } -- 2.53.0
