From patchwork Tue Nov 1 11:06:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9407179 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 5A79260234 for ; Tue, 1 Nov 2016 11:07:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DC1A29827 for ; Tue, 1 Nov 2016 11:07:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41A0429829; Tue, 1 Nov 2016 11:07:37 +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 7032629827 for ; Tue, 1 Nov 2016 11:07:35 +0000 (UTC) Received: from localhost ([::1]:46891 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1Wuj-00019N-Lw for patchwork-qemu-devel@patchwork.kernel.org; Tue, 01 Nov 2016 07:07:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1WuV-000198-Bg for qemu-devel@nongnu.org; Tue, 01 Nov 2016 07:07:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1WuQ-0003GW-WD for qemu-devel@nongnu.org; Tue, 01 Nov 2016 07:07:19 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:36784) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c1WuQ-0003G8-Ot for qemu-devel@nongnu.org; Tue, 01 Nov 2016 07:07:14 -0400 Received: by mail-wm0-x242.google.com with SMTP id c17so22208527wmc.3 for ; Tue, 01 Nov 2016 04:07:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:to:cc:subject:date; bh=mBcTaUQGJ4Qe6Zss8/bVvh5iJgZTYKng/EhAhSotPxU=; b=lbeYuVgeUIKNv7gsnptnkL8LNwvLJBFLBzl8sEQQ+K/r5YS3YfZk2dcfQx0DiciPaU VDi53KbRHkmAOO2aLoJOlC/VhFYdW+LDd1kCBfnd3xT+bvmice/L956Rsdjoy9j7gg13 lVk4DyyX1CKDWNLDD1+44iCWpquEq/mhAHH8kfaGGCqDAGwna+OjU95ZVX1Z3UjMk0D9 JF42MG8C5Gdrrt+wvAlRbvjx+zqiDInleh16+JrWm/jS6lA4eV0t44c0D/0yMliU02C1 UPI8GG8wEIFf76nN3JlHHqVesCozI0oOPfDICLAe4ranREdLO2+L1qB1RARKbJMLRc0t Hsbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:from:to:cc:subject:date; bh=mBcTaUQGJ4Qe6Zss8/bVvh5iJgZTYKng/EhAhSotPxU=; b=TwrIWmD6+nyfAa9s6nVLz8Wohb5ZwoSJjqOHm/brdze7RSw2rjNvbhONoeiqqOITkW bfxux+KMLz1ni51RQ9LJNcm6FNpRVy8NkUo+pmtMRorYfTO+pxfKw2BY08aFUfePGopC aESZMg9RhGSK0BevZq9L7qAyZAr4XxBOkY0a2zogxSRrPv6KW1qwDehQ9Jkl2UqGcL5q AtVyqvc8xhePYLUpyWNOcJEz2xAlq+RfLKnljrJVh9entVgeMMTFPpY+eZmpOSFoykqi 6V3+l6AhHDaQLO6vM7BgUhSIKQsygmXZXSKZmPcTiJD4SCYjL5X5+gEk6bv09ZMGeXUv Hvzw== X-Gm-Message-State: ABUngvdyjxYRrjrjppKXLWkdtOBG6rfEcFoPpWtXjfLko1tlKGnPMltFNMiPPpkW0nS2bQ== X-Received: by 10.28.191.3 with SMTP id p3mr1182292wmf.112.1477998433612; Tue, 01 Nov 2016 04:07:13 -0700 (PDT) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id o62sm29724454wmg.12.2016.11.01.04.07.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Nov 2016 04:07:12 -0700 (PDT) Message-ID: <58187760.41d71c0a.cca75.4cb9@mx.google.com> X-Google-Original-Message-ID: <1477998418-4941-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, qemu-devel@nongnu.org Date: Tue, 1 Nov 2016 04:06:58 -0700 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: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH] virtio-gpu: fix memory leak in update_cursor_data_virgl 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 update_cursor_data_virgl function, if the 'width'/ 'height' is not equal to current cursor's width/height it will return without free the 'data' allocated previously. This will lead a memory leak issue. This patch fix 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 60bce94..5f32e1a 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -84,6 +84,7 @@ static void update_cursor_data_virgl(VirtIOGPU *g, if (width != s->current_cursor->width || height != s->current_cursor->height) { + free(data); return; }