Re: [PATCH 2/2] efi_loader: consider type of platform_get_rng_device() return value
Ilias Apalodimas <[email protected]>
| Newsgroups | org.u-boot-project.lists.u-boot |
|---|---|
| Message-ID | <CAC_iWjLFuWJApD0EZmgSWUG1c5F5vVoMGe8u0cNeB=xjGcEiVQ@mail.gmail.com> |
Hi Heinrich, On Thu, 20 Aug 2026 at 16:08, Heinrich Schuchardt <[email protected]> wrote: > > 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. I had a similar comment in patch#1. I am fine fixing this this way, but shouldn't we also remove the second error message in efi_rng_register()? Thanks /Ilias > > 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 >