virtio: rng: Handle oversized return buffers

If extra random bytes are returned, truncate and use the requested number
instead of returning an error.

Signed-off-by: Kavin Gunasekara <kavin.gunasekara@arm.com>
Signed-off-by: Meet Patel <meet.patel2@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
This commit is contained in:
Kavin Gunasekara
2026-03-09 16:55:05 +00:00
committed by Tom Rini
parent 8019e3b35d
commit e0eef12a1f

View File

@@ -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;