[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [UNIKRAFT PATCH 3/5] plat/drivers/virtio: Add error check for return value



Hi Vlad, looks good, thanks.

Reviewed-by: Felipe Huici <felipe.huici@xxxxxxxxx>

On Sat, Nov 21, 2020 at 4:08 PM Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx> wrote:
If virtio_config_get return an error then tag_len does
not get initialized and the next calloc is ran with an
unitialized length.
---
 plat/drivers/virtio/virtio_9p.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/plat/drivers/virtio/virtio_9p.c b/plat/drivers/virtio/virtio_9p.c
index fe0d69ab..045ce42f 100644
--- a/plat/drivers/virtio/virtio_9p.c
+++ b/plat/drivers/virtio/virtio_9p.c
@@ -345,9 +345,13 @@ static int virtio_9p_feature_negotiate(struct virtio_9p_device *d)
                goto out;
        }

-       virtio_config_get(d->vdev,
+       if (virtio_config_get(d->vdev,
                          __offsetof(struct virtio_9p_config, tag_len),
-                         &tag_len, 1, sizeof(tag_len));
+                         &tag_len, 1, sizeof(tag_len)))
+       {
+               rc = -EAGAIN;
+               goto out;
+       }

        d->tag = uk_calloc(a, tag_len + 1, sizeof(*d->tag));
        if (!d->tag) {
--
2.27.0



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.