From patchwork Thu Mar 30 12:27:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9654081 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 5E40D60349 for ; Thu, 30 Mar 2017 12:28:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E175205FC for ; Thu, 30 Mar 2017 12:28:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 410F128595; Thu, 30 Mar 2017 12:28:59 +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 E4EC0205FC for ; Thu, 30 Mar 2017 12:28:57 +0000 (UTC) Received: from localhost ([::1]:35369 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctZCC-0004Ns-MW for patchwork-qemu-devel@patchwork.kernel.org; Thu, 30 Mar 2017 08:28:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45770) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctZAq-0003s1-9L for qemu-devel@nongnu.org; Thu, 30 Mar 2017 08:27:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctZAl-0008O3-Dc for qemu-devel@nongnu.org; Thu, 30 Mar 2017 08:27:32 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:35944) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ctZAl-0008NY-8V for qemu-devel@nongnu.org; Thu, 30 Mar 2017 08:27:27 -0400 Received: by mail-pg0-x244.google.com with SMTP id 81so9668501pgh.3 for ; Thu, 30 Mar 2017 05:27:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=jTegmYaI+K6Z4Cbx0JtnReH07TI9KIWPxfZ3nzQr69I=; b=Lce0/5UBWeL42dxXbJHR2QaKSztYASuJFafAy5257mxxXNo8v+H7Ry1vLgEN9damOw 1ABVS4OjMdz5fM8CR3P3RHoK7d/yyPKyIDVcFmfMYaH7SfzTWbrCl595HhEjX03FD4tR Rg+nXQ/5s8n3/WFEk+41jRB1tFriK8+eNIfy8w2rKbrLJhw/7IrlNBtOu3oaB4vmwkW6 JTFOhhZVBVCW4ycTvOEUsKJqLfE05Koa1knO0eWQ0ukT3dnR7ZZogxRchTL6l9KHIV/v lGLaq9d+/Q0VqEuqscG9gnSrJXjeINecGOOd3eFSvUxmKqz/M5cUniIsjrVu0f/k5FHB 2leA== 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=jTegmYaI+K6Z4Cbx0JtnReH07TI9KIWPxfZ3nzQr69I=; b=QUdFBG8JLKACqvhU3b+kcAO+ZwtXvt8wDzSMA/WdJZ6pPERfry2tPd4vOgdQLeokK6 e8OHrnQy5vCqjRbe22JpNyJch0BNoNBvDh/5IduvIngvxiCJ24YNXH88uEkIB/3v+bRG TR+ShUXOF5QpkcTshEDi/YXJugbd3hvx/AnS/FAhhSpytbTGK/YitBrXXfeJVz8fa/K4 X8j2veTA1IeUyYAStul2sSYSEBGhVK+k9hPg/zN7o5wVVLjWQZ98HMYWONGC+0DIa4ZL UvqySSO4CN48T4ken6GBruY7L+XDfZl9PMCiYLVgHRBrq+qEzosE3OdNejdaUs/cJXhS 94Dw== X-Gm-Message-State: AFeK/H2wztXm7Brnbv20EsarY4Y/5mlnWJPUMglWIpQN/AIXSxUemdgMwG7rM/IipNesSQ== X-Received: by 10.98.55.197 with SMTP id e188mr5960120pfa.116.1490876846198; Thu, 30 Mar 2017 05:27:26 -0700 (PDT) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id u129sm4422701pfu.48.2017.03.30.05.27.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Mar 2017 05:27:25 -0700 (PDT) From: Li Qiang X-Google-Original-From: Li Qiang To: groug@kaod.org Date: Thu, 30 Mar 2017 05:27:14 -0700 Message-Id: <1490876834-61392-1-git-send-email-liqiang6-s@360.cn> 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:400e:c05::244 Subject: [Qemu-devel] [PATCH] 9pfs: fix migration_block leak 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 , qemu-devel@nongnu.org, ppandit@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The guest can leave the pdu->s->migration_blocker exists by attach but not remove a fid. Then if we hot unplug the 9pfs device, the v9fs_reset() just free the fids, but not free the migration_blocker. This will leak a memory leak. This patch avoid this. Signed-off-by: Li Qiang Reviewed-by: Eric Blake --- hw/9pfs/9p.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 48babce..b55c02d 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -548,6 +548,12 @@ static void coroutine_fn virtfs_reset(V9fsPDU *pdu) free_fid(pdu, fidp); } } + + if (pdu->s->migration_blocker) { + migrate_del_blocker(pdu->s->migration_blocker); + error_free(pdu->s->migration_blocker); + pdu->s->migration_blocker = NULL; + } } #define P9_QID_TYPE_DIR 0x80