From patchwork Tue Nov 29 02:29:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9450853 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AC28E6071C for ; Tue, 29 Nov 2016 02:30:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CF1F28118 for ; Tue, 29 Nov 2016 02:30:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 916DA2811D; Tue, 29 Nov 2016 02:30:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 20F2D28118 for ; Tue, 29 Nov 2016 02:30:09 +0000 (UTC) Received: from localhost ([::1]:34169 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBYBM-0001Ys-F8 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 28 Nov 2016 21:30:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBYB2-0001YY-Ej for qemu-devel@nongnu.org; Mon, 28 Nov 2016 21:29:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBYAz-0004W1-0r for qemu-devel@nongnu.org; Mon, 28 Nov 2016 21:29:48 -0500 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]:34670) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cBYAy-0004Vn-Qn for qemu-devel@nongnu.org; Mon, 28 Nov 2016 21:29:44 -0500 Received: by mail-qk0-x244.google.com with SMTP id y205so15858883qkb.1 for ; Mon, 28 Nov 2016 18:29:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=8JLvgiCzfS4E9rzwmRHU7iKjD1L3xspbu3bwEHNGIaM=; b=hSO9vUgkwKGeEFLW9TkWUt2wy+x3BaiJLGRfH9/EV8/G5kYAvfESV6HWUrmJOP/ZrJ WV6Bz2AgU9qITkB3pOvqEjBdqC0xNjVWFUgNHhUWcZ/O7PRdXAHM0WmeBM3WcVbwDSB3 8tndhDzmPa8WtgyF/zOTyhu604n5deUFtnD4OeTKuIpid6O4tEJ1esF4LITFx3RW/ZLb x6Ov9SsVPaAkysAhPjXpq5KhoBH4dc5GGVY9mb9RZVi6RD4/v8q+QiwqhyfyEgKvyvTf kVaPfWekmn0PWtjKr/2Pn5RxnVerwj6QtRI92L6aGMqyNM0v8DaLqdcM9ey3KSRhjUfU VKaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=8JLvgiCzfS4E9rzwmRHU7iKjD1L3xspbu3bwEHNGIaM=; b=lycE/O4Zp6SUHiPyYfFt0JOpXoW9LNPQi5JIF7K3eRlVSJ/gjrV2RRQxDNJpqQEBq9 3XvWFc6+Gp+rE8+73c2IzwRGBypVg0p2ST44AUEMvHqFoSPhwpE68AOoGR53rA2lne56 Z2F37Xq1ljtzW89sUO6dw/1eXCYwMYarofRqA+bzAA988D1HmmsrMrmMdkp3RAE4JicZ KAquzNER15YlsAKtgX2wGDZllG+iKG4i+bguftIgTO22iIJSW0KyvbVRs90dU/5Mu2vt sV+I4gl/M6SMURnH2ZLVJ40KW1wrgay1uCNe317Lntr5ZmKZBYPP8Imtv7Y7SgnntBm+ tTaw== X-Gm-Message-State: AKaTC02uwPaJdFGyuz2oT42SSWGgigkIfeaii1J9dXYu1VZrx4mnqAPLuO1WPTbvOzfGkw== X-Received: by 10.55.77.137 with SMTP id a131mr22409083qkb.249.1480386583644; Mon, 28 Nov 2016 18:29:43 -0800 (PST) Received: from localhost.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id 14sm29847071qtp.19.2016.11.28.18.29.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 18:29:43 -0800 (PST) From: Li Qiang To: kraxel@redhat.com, marcandre.lureau@gmail.com, qemu-devel@nongnu.org Date: Mon, 28 Nov 2016 21:29:25 -0500 Message-Id: <1480386565-10077-1-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c09::244 Subject: [Qemu-devel] [PATCH] virtio-gpu: call cleanup mapping function in resource destroy X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang , liqiang6-s@360.cn Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP If the guest destroy the resource before detach banking, the 'iov' and 'addrs' field in resource is not freed thus leading memory leak issue. This patch avoid this. Signed-off-by: Li Qiang Reviewed-by: Marc-André Lureau --- hw/display/virtio-gpu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 60bce94..98dadf2 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -28,6 +28,8 @@ static struct virtio_gpu_simple_resource* virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); +static void virtio_gpu_cleanup_mapping(struct virtio_gpu_simple_resource *res); + #ifdef CONFIG_VIRGL #include #define VIRGL(_g, _virgl, _simple, ...) \ @@ -358,6 +360,7 @@ static void virtio_gpu_resource_destroy(VirtIOGPU *g, struct virtio_gpu_simple_resource *res) { pixman_image_unref(res->image); + virtio_gpu_cleanup_mapping(res); QTAILQ_REMOVE(&g->reslist, res, next); g_free(res); }