[PATCH 2/2] virtio: rng: Handle oversized return buffers

Andre Przywara andre.przywara at arm.com
Tue Mar 3 12:48:37 CET 2026


Hi,

On 2/17/26 14:29, Kavin Gunasekara wrote:
> If extra random bytes are returned, truncate and use the requested number
> instead of returning an error.
> 
> Signed-off-by: Kavin Gunasekara <kavin.gunasekara at arm.com>

Reviewed-by: Andre Przywara <andre.przywara at arm.com>

Cheers,
Andre

> ---
>   drivers/virtio/virtio_rng.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/virtio/virtio_rng.c b/drivers/virtio/virtio_rng.c
> index 90a371a59cc..c6de62142bb 100644
> --- a/drivers/virtio/virtio_rng.c
> +++ b/drivers/virtio/virtio_rng.c
> @@ -46,7 +46,7 @@ static int virtio_rng_read(struct udevice *dev, void *data, size_t len)
>   			;
>   
>   		if (rsize > sg.length)
> -			return -EIO;
> +			rsize = sg.length;
>   
>   		memcpy(ptr, buf, rsize);
>   		len -= rsize;



More information about the U-Boot mailing list