qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PULL 6/6] virtio-gpu: add live migration support


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PULL 6/6] virtio-gpu: add live migration support
Date: Tue, 14 Jun 2016 15:26:52 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0


On 06/06/2016 09:06, Gerd Hoffmann wrote:
> +    while (resource_id != 0) {
> +        res = g_new0(struct virtio_gpu_simple_resource, 1);
> +        res->resource_id = resource_id;
> +        res->width = qemu_get_be32(f);
> +        res->height = qemu_get_be32(f);
> +        res->format = qemu_get_be32(f);
> +        res->iov_cnt = qemu_get_be32(f);
> +
> +        /* allocate */
> +        pformat = get_pixman_format(res->format);
> +        if (!pformat) {
> +            return -EINVAL;

Coverity says, all the "return" statements in this loop leak res.

Paolo

> +        }
> +        res->image = pixman_image_create_bits(pformat,
> +                                              res->width, res->height,
> +                                              NULL, 0);
> +        if (!res->image) {
> +            return -EINVAL;
> +        }
> +
> +        res->addrs = g_new(uint64_t, res->iov_cnt);
> +        res->iov = g_new(struct iovec, res->iov_cnt);
> +
> +        /* read data */
> +        for (i = 0; i < res->iov_cnt; i++) {
> +            res->addrs[i] = qemu_get_be64(f);
> +            res->iov[i].iov_len = qemu_get_be32(f);
> +        }
> +        qemu_get_buffer(f, (void *)pixman_image_get_data(res->image),
> +                        pixman_image_get_stride(res->image) * res->height);
> +
> +        /* restore mapping */
> +        for (i = 0; i < res->iov_cnt; i++) {
> +            hwaddr len = res->iov[i].iov_len;
> +            res->iov[i].iov_base =
> +                cpu_physical_memory_map(res->addrs[i], &len, 1);
> +            if (!res->iov[i].iov_base || len != res->iov[i].iov_len) {
> +                return -EINVAL;
> +            }
> +        }
> +
> +        QTAILQ_INSERT_HEAD(&g->reslist, res, next);
> +
> +        resource_id = qemu_get_be32(f);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]