From patchwork Sun Jan 22 07:42:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9530815 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 DC5416020B for ; Sun, 22 Jan 2017 07:43:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C27FE27FAD for ; Sun, 22 Jan 2017 07:43:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3CB22807E; Sun, 22 Jan 2017 07:43:07 +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 866BA27FAD for ; Sun, 22 Jan 2017 07:43:06 +0000 (UTC) Received: from localhost ([::1]:34777 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cVCno-0006pI-V0 for patchwork-qemu-devel@patchwork.kernel.org; Sun, 22 Jan 2017 02:43:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41914) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cVCnX-0006pD-Ic for qemu-devel@nongnu.org; Sun, 22 Jan 2017 02:42:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cVCnS-0003cB-Pe for qemu-devel@nongnu.org; Sun, 22 Jan 2017 02:42:47 -0500 Received: from mail-io0-x242.google.com ([2607:f8b0:4001:c06::242]:35920) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cVCnS-0003be-KA for qemu-devel@nongnu.org; Sun, 22 Jan 2017 02:42:42 -0500 Received: by mail-io0-x242.google.com with SMTP id q20so12070524ioi.3 for ; Sat, 21 Jan 2017 23:42:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:from:to:cc:subject:date; bh=E3JPZPUrwCo9o9b3C3767X74P45/MPOVk1+uchRPyxk=; b=m5VIhlUQSdqHv7BtXJyBp1UUDWDzKzm9AoYIbtVmOPTAFgusZvSemeGq0z0rSqZg7S LBIAQ9tFoldoxvfC4n5pazzpgPPoF+Gg9VlYzQg+De3oaJZyiHpL/lvR1dHUw6n5xtkp +/eWLOVJ0ODd0jzFym82eadzQOycQOuGa+tQuFRp3ooIaYUHcnErn8g0RirJHcopriX+ Kru87oLmX/zAH3HuTqy6QosM5vTNxxKabJraWJ5OjYyp/XDvZCaNBRCybNBt3J6Wl4AF 4rd/f/+XfC93HMrdQCoZ9U2IskSjGKysqSN0c45+svRd1XVANjR7EOI46WV41H9Jl4qb LSpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:to:cc:subject:date; bh=E3JPZPUrwCo9o9b3C3767X74P45/MPOVk1+uchRPyxk=; b=MhZx0lFaX1YZxZ1ivv70Quqr61tvXLAbWc897s70UprE7Xi91cR+JTdWNf3ZSzpbMf S59kNiPv6keULpvSTCv7RohFgMl9Z+DCp//SxJ5cfsdN4hAl5TGklSQp2S9X/urWkAy8 eOnwDSM/Tl5n05RKWESOO2of+O5qGfPv+nxAc66wXRBPrtQ067pXN/AIPxuxP6juaZPZ oGWbASNpw4VGdG3wBN00Imyz0AZgSEqFkSGTNekrA/8IVw1pNPqMibQvA+AKOIdIZeyE VFQIFKvNILBPz6C2pG8mOwOltLdKkTao1BDKZ2O0qu2SLajQgSpvcowtNxwNacY9IZIJ R/rg== X-Gm-Message-State: AIkVDXIrmd2JCGKPQkByHMd4M6fILq8HgA/JVWSVoRfjbbzMI6oC62C7W16SdGI3Vvnkyg== X-Received: by 10.107.131.39 with SMTP id f39mr19155511iod.40.1485070960441; Sat, 21 Jan 2017 23:42:40 -0800 (PST) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id j88sm7562752ioo.29.2017.01.21.23.42.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Jan 2017 23:42:39 -0800 (PST) Message-ID: <5884626f.5b2f6b0a.1bfff.3037@mx.google.com> X-Google-Original-Message-ID: <1485070953-27598-1-git-send-email-Qiang(liqiang6-s@360.cn)> From: Li Qiang X-Google-Original-From: Li Qiang(liqiang6-s@360.cn) To: kraxel@redhat.com, marcandre.lureau@redhat.com, qemu-devel@nongnu.org Date: Sat, 21 Jan 2017 23:42:33 -0800 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:4001:c06::242 Subject: [Qemu-devel] [PATCH] virtio-gpu: fix memory leak in set scanout 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 Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Li Qiang In virtio_gpu_set_scanout function, when creating the 'rect' its refcount is set to 2, by pixman_image_create_bits and qemu_create_displaysurface_pixman function. This can lead a memory leak issues. This patch avoid this issue. Signed-off-by: Li Qiang Reviewed-by: Marc-André Lureau --- hw/display/virtio-gpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 7a15c61..4aecea3 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -608,6 +608,7 @@ static void virtio_gpu_set_scanout(VirtIOGPU *g, cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; return; } + pixman_image_unref(rect); dpy_gfx_replace_surface(g->scanout[ss.scanout_id].con, scanout->ds); }