From patchwork Thu Dec 29 09:28:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9491119 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 E34FE60838 for ; Thu, 29 Dec 2016 09:29:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE1D6208E3 for ; Thu, 29 Dec 2016 09:29:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF1702094F; Thu, 29 Dec 2016 09:29:12 +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 8007F208E3 for ; Thu, 29 Dec 2016 09:29:10 +0000 (UTC) Received: from localhost ([::1]:34703 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMX1J-00033Z-Lo for patchwork-qemu-devel@patchwork.kernel.org; Thu, 29 Dec 2016 04:29:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMX12-00033I-I9 for qemu-devel@nongnu.org; Thu, 29 Dec 2016 04:28:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cMX0z-0006uZ-DG for qemu-devel@nongnu.org; Thu, 29 Dec 2016 04:28:52 -0500 Received: from mail-io0-x243.google.com ([2607:f8b0:4001:c06::243]:34118) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cMX0z-0006uV-98 for qemu-devel@nongnu.org; Thu, 29 Dec 2016 04:28:49 -0500 Received: by mail-io0-x243.google.com with SMTP id n85so18968111ioi.1 for ; Thu, 29 Dec 2016 01:28:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=BotWAczjfsA+UTq62PL/XFLi7vHF7RT3/TlFAh/PAxs=; b=cI3lUzDr/yLjogzLy6io09rNrkFJbU2yVZsxuUrgfaqwdsNdyg/fwUhk5cCoDx8BmC ooFOwrQZ1M4aLxpx0Cm/5nD3l0c7b7Nn4O01OhpJXbPQR/RlwONzvbLYXSt7bs4MqunR z+sS5kStSlawgGZGBpCayffaZBQpcwR4pJdZjosu7/ejWwZHe+wDgV+egYvrGkScaIZo O0nb1zscOjfCWmk03kGMbJu7K1Qkx/WvS0NZ4BhOcsbqnbvVeIromPUn1bKdvTQQmd0G DAczKckvRWGG0pMTGNpSaYXfUzMU4JY885NpHzwYvMKdjBFOQGyw/tMtFh0OP0KUd7Lu pboQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BotWAczjfsA+UTq62PL/XFLi7vHF7RT3/TlFAh/PAxs=; b=EspVXZYGtL2iGJuHhM9DXkx0LuE6sHfoPTAOQ15K4sdeFmfxatXLw3R177hwqrdwBW L6fEuSUsJWhEStqvxWUxWvL8o556Cru1uUk8k/FZ3o0GuhaarzcQmS+qqmPxfVTmNjWQ 3wbzlJJkJPSJ5tKGOaM9F9a28JIqrFZ3cs00PUNHT/OckoUfH3Mp+Pfgm84BUxsdDbDk ZCr9vY1oSGvfGLTvvvi9bNtlqeghtWG50+A6KA/aZgNC14vY6PlusFVdtBDHFGhzsaAu 6lhr5/fuQl/G52icOHIpmUpfb7uXWCXfq6X2kcRkiJer/FAtFGkDV5nydesbXmE2h9Cs 3nxw== X-Gm-Message-State: AIkVDXJFan7Sjf7pPeIvd2THfSeB1UvypSbtC80E65OWtPXbqnDp75ofWfkhbIGsU3i5xA== X-Received: by 10.107.149.144 with SMTP id x138mr36193174iod.23.1483003728550; Thu, 29 Dec 2016 01:28:48 -0800 (PST) Received: from localhost.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id o65sm25038836ioe.15.2016.12.29.01.28.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Dec 2016 01:28:48 -0800 (PST) From: Li Qiang To: kraxel@redhat.com, marcandre.lureau@redhat.com, qemu-devel@nongnu.org Date: Thu, 29 Dec 2016 04:28:41 -0500 Message-Id: <1483003721-65360-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:4001:c06::243 Subject: [Qemu-devel] [PATCH] virtio-gpu: fix memory leak in resource attach backing 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 In the resource attach backing function, everytime it will allocate 'res->iov' thus can leading a memory leak. This patch avoid this. Signed-off-by: Li Qiang --- hw/display/virtio-gpu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 5f32e1a..045f296 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -705,6 +705,11 @@ virtio_gpu_resource_attach_backing(VirtIOGPU *g, return; } + if (res->iov) { + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; + return; + } + ret = virtio_gpu_create_mapping_iov(&ab, cmd, &res->addrs, &res->iov); if (ret != 0) { cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;