From patchwork Thu Feb 9 07:04:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9564125 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 1E03360236 for ; Thu, 9 Feb 2017 07:05:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D82B8284EB for ; Thu, 9 Feb 2017 07:05:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9AF728512; Thu, 9 Feb 2017 07:05:02 +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 8E93D284EB for ; Thu, 9 Feb 2017 07:05:01 +0000 (UTC) Received: from localhost ([::1]:35964 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbimq-0003M6-KV for patchwork-qemu-devel@patchwork.kernel.org; Thu, 09 Feb 2017 02:05:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59238) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbimN-0003L8-Dn for qemu-devel@nongnu.org; Thu, 09 Feb 2017 02:04:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbimI-00027S-IM for qemu-devel@nongnu.org; Thu, 09 Feb 2017 02:04:31 -0500 Received: from mail-io0-x243.google.com ([2607:f8b0:4001:c06::243]:33841) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cbimI-00027L-DQ for qemu-devel@nongnu.org; Thu, 09 Feb 2017 02:04:26 -0500 Received: by mail-io0-x243.google.com with SMTP id c80so1278281iod.1 for ; Wed, 08 Feb 2017 23:04:24 -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:in-reply-to:references; bh=OjFqSklt0aGwuxpKi6JG3maP6XQWU8cLPKKCi9LnmOI=; b=qrw31+xlcbto3C6t+DJQrfU+XmrWlZ7455avRussrCyT8RYsPu5K+HJJP/QF7My7VZ v86oTd03exp5/qeQLTnwCn0zO2O0Qpn8cBDcaWiwSMWU2tXXhoIhMxb0KWxJetQIrGmZ 2ovdv9rApf1e7Ue8ObMwSwrVcYI4XBggj5yjdXrdIU9dLGUBFtqA6ZB/e0jRUtwAEMXR lhNM2CUAb3p6z3O3MONsCM+EcTz7M0YzqyiRypju20vBUG1egUEOMxWTgjxg2XpOwXSK mnnleFYnN0bH148w7KsKLw4hT3tlFS4CbVlJsRzZQDUFm3XKsSE7CFLirQghLLmIe+K/ djUg== 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:in-reply-to :references; bh=OjFqSklt0aGwuxpKi6JG3maP6XQWU8cLPKKCi9LnmOI=; b=SnRjh29fJqwzzeBQVd6aCi2nnevv4n1T59jta4sVDSBVm6a09oPhhiRglmLfZ9zs+R bre5UqqLlAIpg2vraDu8E2Bkx9euzUSLyPWWJjfi10HVM9JR5gfdofo3B5lzJsR7Cyhd uK7aHemCLPymmvoS3GYwxWNnv3WW0uM501jVf2fPakJw452rdCFcVEcCoRbCUK07JCyC XcBdsG0txRvhC8fl+aZRImCvCdeOFTI77dCTiGhp+IcEpOKdMdfKSY/jAaHOeM7jSE7i DF8Tcb3KM9BYT1zIcs2VNwgAXEwrIT3dNV9nLCaOO8bgPojYWmNyLrp+RVb57c0kzOVr EhWw== X-Gm-Message-State: AMke39nqFcIyunIXLmAXy4TIvkOLpU9SUamsmnEnM+HRrNmbBjwt05yimMRmKNkQFM+ydQ== X-Received: by 10.107.51.68 with SMTP id z65mr1832314ioz.53.1486623863647; Wed, 08 Feb 2017 23:04:23 -0800 (PST) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id e11sm2483474ita.10.2017.02.08.23.04.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Feb 2017 23:04:23 -0800 (PST) From: Li Qiang X-Google-Original-From: Li Qiang To: jsnow@redhat.com, qemu-devel@nongnu.org Date: Wed, 8 Feb 2017 23:04:04 -0800 Message-Id: <1486623844-13140-3-git-send-email-liqiang6-s@360.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1486623844-13140-1-git-send-email-liqiang6-s@360.cn> References: <1486623844-13140-1-git-send-email-liqiang6-s@360.cn> 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 2/2] ide: ahci: call cleanup function in ahci unit 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 This can avoid memory leak when hotunplug the ahci device. Signed-off-by: Li Qiang --- hw/ide/ahci.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 3c19bda..56f68a8 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1485,6 +1485,14 @@ void ahci_realize(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports) void ahci_uninit(AHCIState *s) { + int i; + + for (i = 0; i < s->ports; i++) { + AHCIDevice *ad = &s->dev[i]; + + ide_unregister_restart_cb(&ad->port); + ide_exit(&ad->port); + } g_free(s->dev); }