From patchwork Mon Oct 10 10:41:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9369333 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 3A19860487 for ; Mon, 10 Oct 2016 10:42:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BDAB29521 for ; Mon, 10 Oct 2016 10:42:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 206E52956E; Mon, 10 Oct 2016 10:42:14 +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 EC59E29521 for ; Mon, 10 Oct 2016 10:42:12 +0000 (UTC) Received: from localhost ([::1]:48774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btY27-0006CG-Nx for patchwork-qemu-devel@patchwork.kernel.org; Mon, 10 Oct 2016 06:42:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btY1q-0006AM-6w for qemu-devel@nongnu.org; Mon, 10 Oct 2016 06:41:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btY1k-0005kA-9u for qemu-devel@nongnu.org; Mon, 10 Oct 2016 06:41:53 -0400 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]:35818) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btY1k-0005jO-2b for qemu-devel@nongnu.org; Mon, 10 Oct 2016 06:41:48 -0400 Received: by mail-lf0-x244.google.com with SMTP id x79so5861444lff.2 for ; Mon, 10 Oct 2016 03:41:47 -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=buuJ2mj2zRcM1mvY/yHeDSNnXkM8yyOLMD3XpATw89c=; b=vFnmyJxeRn6pWmowtZneLUEfYqyPDg4m9AwYPguPaos5NBEcaOQNECC0mUwd958FMz Ezo2B8h4YUrcrD097w1j8oNp3EURqq0VpbJEkNy2i7swVA7hN+ptqkK/3yNwSEf9dSX+ gVhu1UoyxDThYM1Iu1teVuxkfiXhiwrmAv4egtHKuBGwPv6ayQB6A2Pt4o479A8/TAbd b3BylOnk7Z04IzXuStXyPKFKY0+e+/ifCGdAW1k2yQLBuw6zV8jOxFqYLyep07yAKGEc 0r4S+Ag4XxPj9hAugqyMgtuYTw+RrbrkBIN9YTZAzDxOVdlDKNdLniBkl4SCVIiNXC04 pVUA== 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=buuJ2mj2zRcM1mvY/yHeDSNnXkM8yyOLMD3XpATw89c=; b=DMSE8P5gxgljUkaef1d8vouedGD1Utthc24tjUWabBxSTe6T6PE85rkBmJD5B5++On OReMyxv7flUvS0Gfw6Y7f9MhWwCrutO6VV1BK7sSbDrIe4qGlz6eYunXg2m43mPJNrmv M6MiIN7yPMCvnHDvKMWXyHzOi47YvaLuXVsXbSFLH+7uGAgR/Go8JmaJIzvnZ/JHNWq4 M/BhnA9IPf7wnYKCJe1VR8KTcKJFa7Us1qGJzGhGfUYgsH4nkYURF7Px5BAZWVt2guQJ 5Ty9H+eNYtjJiVRCQNkNmzUs5HOGxdirjAn9jbTN91lZOz/KUzubA3T0atek8GjzdD9W vcmQ== X-Gm-Message-State: AA6/9Rnp9Lq0Leciu3UguQ172hyXuHMU5gd/RdmlQyjx2nqulEIC4XBGOn9yKGNMz98x0w== X-Received: by 10.194.52.3 with SMTP id p3mr34917901wjo.55.1476096107127; Mon, 10 Oct 2016 03:41:47 -0700 (PDT) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id jt8sm34631748wjc.33.2016.10.10.03.41.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Oct 2016 03:41:46 -0700 (PDT) Message-ID: <57fb706a.a8c8c20a.2886d.5bd5@mx.google.com> X-Google-Original-Message-ID: <1476096098-4294-1-git-send-email-Qiang(liqiang6-s@360.cn)> From: Li Qiang X-Google-Original-From: Li Qiang(liqiang6-s@360.cn) To: groug@kaod.org, qemu-devel@nongnu.org Date: Mon, 10 Oct 2016 03:41:38 -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:4010:c07::244 Subject: [Qemu-devel] [PATCH] 9pfs: fix memory leak in v9fs_xattrcreate 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 The 'fs.xattr.value' field in V9fsFidState object doesn't consider the situation that this field has been allocated previously. Every time, it will be allocated directly. This leads a host memory leak issue. This patch fix this. Signed-off-by: Li Qiang Reviewed-by: Greg Kurz --- hw/9pfs/9p.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 8751c19..e4040dc 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -3282,6 +3282,7 @@ static void v9fs_xattrcreate(void *opaque) xattr_fidp->fs.xattr.flags = flags; v9fs_string_init(&xattr_fidp->fs.xattr.name); v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name); + g_free(xattr_fidp->fs.xattr.value); xattr_fidp->fs.xattr.value = g_malloc0(size); err = offset; put_fid(pdu, file_fidp);