aboutsummaryrefslogtreecommitdiff
path: root/drivers/virtio/virtio_rng.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/virtio/virtio_rng.c')
-rw-r--r--drivers/virtio/virtio_rng.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/virtio/virtio_rng.c b/drivers/virtio/virtio_rng.c
index 9314c0a..b85545c 100644
--- a/drivers/virtio/virtio_rng.c
+++ b/drivers/virtio/virtio_rng.c
@@ -41,6 +41,9 @@ static int virtio_rng_read(struct udevice *dev, void *data, size_t len)
while (!virtqueue_get_buf(priv->rng_vq, &rsize))
;
+ if (rsize > sg.length)
+ return -EIO;
+
memcpy(ptr, buf, rsize);
len -= rsize;
ptr += rsize;