From patchwork Wed Jan 4 08:43:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9496275 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 62F64606B4 for ; Wed, 4 Jan 2017 08:43:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5295D2711E for ; Wed, 4 Jan 2017 08:43:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4392E2780C; Wed, 4 Jan 2017 08:43:50 +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 5E31A2711E for ; Wed, 4 Jan 2017 08:43:48 +0000 (UTC) Received: from localhost ([::1]:37935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cOhAg-0004i3-Uv for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Jan 2017 03:43:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cOhAQ-0004hy-AU for qemu-devel@nongnu.org; Wed, 04 Jan 2017 03:43:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cOhAL-0003kZ-F6 for qemu-devel@nongnu.org; Wed, 04 Jan 2017 03:43:30 -0500 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:33059) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cOhAL-0003kN-Aa for qemu-devel@nongnu.org; Wed, 04 Jan 2017 03:43:25 -0500 Received: by mail-oi0-x241.google.com with SMTP id f201so73819922oib.0 for ; Wed, 04 Jan 2017 00:43:25 -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=c1UC2zQBWV5m2EASLxVuwu5/7gE9SZwGfcEt1N47Tqc=; b=gQYjFbxDMNy39iazBHM+fkNQMo/KB3hsEtA9e2QM/jAAupD1bLrVaa3tgLj6FWuxL+ VWYnU/Qgq+L2MCVX0c59uaLHt59XI/OdizOBucw68fay7Edr9sZCqh4sGB+c/R0R/YAB eeViI4Yvv9nur3RfW7HreYSbRaMWB1qt6ZRaEo7Cyo5q8WOOjGMwStwo8qt2wcj2uvqw w3gpH4ODMGkgIk9qS/SP+h9rgx5ACLQnLwkzkvD3B6oPk9a2XRV8PMEByPfi7z8L55FO iShDqvEXNZYHqgBTYy90C8a4lDN3nAknXihiCV9C3gSKmxgX+F9LlH5rDmZOXWfY4YoL mz+w== 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=c1UC2zQBWV5m2EASLxVuwu5/7gE9SZwGfcEt1N47Tqc=; b=kbBsJ2OoCnYGNzh7kdqRTtU4jcSjSVvrNcO0nznq3dZWB60DYNUMsps+Aa66/JDBZE FhWxSMlBu16TcagKXMSufRo4lM7pMM7uZYwd93Y16Vsc7IwoIVhs0iFbcfhjg8q+j6+L nOqua9E3A/14iWcNmtEJ5+siJuaItqMwaZx+9agpzT/NyUP4LcF5hDO81/Qqa6fHE8Ha kpubit7TahJPVuGoBa3O605g78xvqEas2RAHRKceYL2TeKBAE6dPR9TeVH6bpXm6fmHa +iUGla4n3mabcVuFZZkosTegEf3Vq1Ycsj26Gal9G1QC1A+T+QfDNRFa8savbaCHe+KT rpMQ== X-Gm-Message-State: AIkVDXKYzQfu5mD/NawBjwp91BYribMrVrZz6b6hD1vwA+liR6PRHfTMPMB2w18K7evZmQ== X-Received: by 10.202.235.78 with SMTP id j75mr32166047oih.74.1483519404453; Wed, 04 Jan 2017 00:43:24 -0800 (PST) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id w48sm21782481otw.33.2017.01.04.00.43.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jan 2017 00:43:23 -0800 (PST) Message-ID: <586cb5ab.f31d9d0a.38ac3.acf2@mx.google.com> X-Google-Original-Message-ID: <1483519396-5820-1-git-send-email-Qiang(liqiang6-s@360.cn)> From: Li Qiang X-Google-Original-From: Li Qiang(liqiang6-s@360.cn) To: mst@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org Date: Wed, 4 Jan 2017 00:43:16 -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:4003:c06::241 Subject: [Qemu-devel] [PATCH] serial: fix memory leak in serial exit 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 serial_exit_core function doesn't free some resources. This can lead memory leak when hotplug and unplug. This patch avoid this. Signed-off-by: Li Qiang Acked-by: Michael S. Tsirkin --- hw/char/serial.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/char/serial.c b/hw/char/serial.c index ffbacd8..67b18ed 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -906,6 +906,16 @@ void serial_realize_core(SerialState *s, Error **errp) void serial_exit_core(SerialState *s) { qemu_chr_fe_deinit(&s->chr); + + timer_del(s->modem_status_poll); + timer_free(s->modem_status_poll); + + timer_del(s->fifo_timeout_timer); + timer_free(s->fifo_timeout_timer); + + fifo8_destroy(&s->recv_fifo); + fifo8_destroy(&s->xmit_fifo); + qemu_unregister_reset(serial_reset, s); }