From patchwork Mon Feb 13 08:17:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 9568975 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 99AA360573 for ; Mon, 13 Feb 2017 08:22:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 889CE27F89 for ; Mon, 13 Feb 2017 08:22:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DD1A27FAE; Mon, 13 Feb 2017 08:22:01 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 26C7127F89 for ; Mon, 13 Feb 2017 08:22:01 +0000 (UTC) Received: from localhost ([::1]:55081 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdBtY-0007id-5D for patchwork-qemu-devel@patchwork.kernel.org; Mon, 13 Feb 2017 03:22:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdBpR-0004vb-EQ for qemu-devel@nongnu.org; Mon, 13 Feb 2017 03:17:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cdBpN-0004b2-0N for qemu-devel@nongnu.org; Mon, 13 Feb 2017 03:17:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54984) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cdBpM-0004ZM-RR for qemu-devel@nongnu.org; Mon, 13 Feb 2017 03:17:40 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6780A128D for ; Mon, 13 Feb 2017 08:17:40 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-154.ams2.redhat.com [10.36.116.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 197392D5DA; Mon, 13 Feb 2017 08:17:39 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id E6C9480DE7; Mon, 13 Feb 2017 09:17:36 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 13 Feb 2017 09:17:27 +0100 Message-Id: <1486973851-21645-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1486973851-21645-1-git-send-email-kraxel@redhat.com> References: <1486973851-21645-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 13 Feb 2017 08:17:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/6] virtio-gpu: fix resource leak in virgl_cmd_resource_unref 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: Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When the guest sends VIRTIO_GPU_CMD_RESOURCE_UNREF without detaching the backing storage beforehand (VIRTIO_GPU_CMD_RESOURCE_DETACH_BACKING) we'll leak memory. This patch fixes it for 3d mode, simliar to the 2d mode fix in commit "b8e2392 virtio-gpu: call cleanup mapping function in resource destroy". Reported-by: 李强 Signed-off-by: Gerd Hoffmann Message-id: 1485167210-4757-1-git-send-email-kraxel@redhat.com --- hw/display/virtio-gpu-3d.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c index f96a0c2..ecb09d1 100644 --- a/hw/display/virtio-gpu-3d.c +++ b/hw/display/virtio-gpu-3d.c @@ -77,10 +77,18 @@ static void virgl_cmd_resource_unref(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_resource_unref unref; + struct iovec *res_iovs = NULL; + int num_iovs = 0; VIRTIO_GPU_FILL_CMD(unref); trace_virtio_gpu_cmd_res_unref(unref.resource_id); + virgl_renderer_resource_detach_iov(unref.resource_id, + &res_iovs, + &num_iovs); + if (res_iovs != NULL && num_iovs != 0) { + virtio_gpu_cleanup_mapping_iov(res_iovs, num_iovs); + } virgl_renderer_resource_unref(unref.resource_id); }