From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkSt2-00012p-QF for qemu-devel@nongnu.org; Fri, 09 Oct 2015 04:18:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkSsx-0003Il-L5 for qemu-devel@nongnu.org; Fri, 09 Oct 2015 04:18:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35404) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkSsx-0003IR-Fs for qemu-devel@nongnu.org; Fri, 09 Oct 2015 04:18:39 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 87EF119F201 for ; Fri, 9 Oct 2015 08:18:38 +0000 (UTC) From: Gerd Hoffmann Date: Fri, 9 Oct 2015 10:18:27 +0200 Message-Id: <1444378714-15190-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1444378714-15190-1-git-send-email-kraxel@redhat.com> References: <1444378714-15190-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL 04/11] virtio-gpu: move iov free to virtio_gpu_cleanup_mapping_iov List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , "Michael S. Tsirkin" For symmetry reasons: virtio_gpu_create_mapping_iov() allocates it so virtio_gpu_cleanup_mapping_iov() should free it, otherwise it's easy to miss a free() needed and leak memory. Signed-off-by: Gerd Hoffmann Reviewed-by: Max Reitz --- hw/display/virtio-gpu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index a67d927..73bd9b6 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -563,7 +563,6 @@ int virtio_gpu_create_mapping_iov(struct virtio_gpu_resource_attach_backing *ab, __func__, ab->resource_id, i); virtio_gpu_cleanup_mapping_iov(*iov, i); g_free(ents); - g_free(*iov); *iov = NULL; return -1; } @@ -580,12 +579,12 @@ void virtio_gpu_cleanup_mapping_iov(struct iovec *iov, uint32_t count) cpu_physical_memory_unmap(iov[i].iov_base, iov[i].iov_len, 1, iov[i].iov_len); } + g_free(iov); } static void virtio_gpu_cleanup_mapping(struct virtio_gpu_simple_resource *res) { virtio_gpu_cleanup_mapping_iov(res->iov, res->iov_cnt); - g_free(res->iov); res->iov = NULL; res->iov_cnt = 0; } -- 1.8.3.1