From patchwork Thu Mar 2 10:08:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9599827 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 60FD6600CB for ; Thu, 2 Mar 2017 10:10:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B4DC2858F for ; Thu, 2 Mar 2017 10:10:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D4672859B; Thu, 2 Mar 2017 10:10:35 +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 854352858F for ; Thu, 2 Mar 2017 10:10:34 +0000 (UTC) Received: from localhost ([::1]:51363 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjNgv-0004m9-D2 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 02 Mar 2017 05:10:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjNfG-0003jA-5L for qemu-devel@nongnu.org; Thu, 02 Mar 2017 05:08:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjNfF-0007iT-85 for qemu-devel@nongnu.org; Thu, 02 Mar 2017 05:08:50 -0500 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:35366) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cjNfF-0007iB-2f for qemu-devel@nongnu.org; Thu, 02 Mar 2017 05:08:49 -0500 Received: by mail-pf0-x242.google.com with SMTP id 67so1972093pfg.2 for ; Thu, 02 Mar 2017 02:08: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:in-reply-to:references; bh=Osxwj7YPDhQaVrThvDo3bsLH2oEpxuEyahesqk/tcGo=; b=ctsIiN6pdPpdDPQzSMcKsxDqyKoHX2aUMTLFS2NOnwUE+Tf4dFCuxaA9dTe9kaSpYU E9yPXFkKHerAAbnrhP74r2UzVE1StStYBnfJEgbJPIPh93wZsJPds/H2ysfMxdPWrmY0 tIIajc1IRiEhZOm4qNZU3GAWqMvy/8tyk6b6qviZ4AHIRq3kN9VSNS8yfwqZ6LSx+COj swAQpyG4N6SzEctT/oz5RJ5xLgfdfw1dAKoysGxbNDlwJuNcrzWyNw8eoQCwjPvB6Mcx BiImOfcbhhj2GRSN02IGmbd54mfnPm0YFoJZ2ox3yyw9MyFgyetKZ8Tq9XYQjUnKAJOX +udQ== 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=Osxwj7YPDhQaVrThvDo3bsLH2oEpxuEyahesqk/tcGo=; b=SjXI+LuyT6sbl7bn4NJbgLPLxSzpuhgaOweyU9sCsxJzePTkGXAN9xVpOIM/eMlAU6 cBpXBVaKQWfmyxYoXPixGlfJoeGZqWHlgSH3PpWOjYXBNxIFB3w9+o5aqr6XFvofNjwy 5brHftAqb4ztwOzFCoz+11qizoxPnXbvsx+ik9z+g9ISApYpzXa+fLqAzAoxW8Lkk98H 31/BZkURYgxABvEOdcxm6jfKPAtS+5TT2hs+L/JHV11PNpDPme8mczeUHwYaTBJdJ+P4 bdVoax8BQD1TEJeUKXAJKAlDccqmE5utsP/S0W9/p1OaffRLYy3zvpIM9TMA4uwOdP7Y pjMg== X-Gm-Message-State: AMke39msewsDzrVQFgQ9k0xX4lyv//nHonVmuNnXnrj6iwrPU26hDIx8iPaNVe89GfsHyw== X-Received: by 10.84.231.205 with SMTP id g13mr17468443pln.30.1488449328294; Thu, 02 Mar 2017 02:08:48 -0800 (PST) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id l22sm15951965pfk.69.2017.03.02.02.08.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 02:08:47 -0800 (PST) From: Li Qiang X-Google-Original-From: Li Qiang To: jsnow@redhat.com, qemu-devel@nongnu.org Date: Thu, 2 Mar 2017 02:08:13 -0800 Message-Id: <1488449293-80280-4-git-send-email-liqiang6-s@360.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1488449293-80280-1-git-send-email-liqiang6-s@360.cn> References: <1488449293-80280-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:400e:c00::242 Subject: [Qemu-devel] [PATCH 3/3] 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: pbonzini@redhat.com, Li Qiang , 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 This can avoid memory leak when hotunplug the ahci device. Signed-off-by: Li Qiang --- hw/ide/ahci.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 6a17acf..f60826d 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1485,6 +1485,18 @@ void ahci_realize(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports) void ahci_uninit(AHCIState *s) { + int i, j; + + for (i = 0; i < s->ports; i++) { + AHCIDevice *ad = &s->dev[i]; + + for (j = 0; j < 2; j++) { + IDEState *s = &ad->port.ifs[j]; + + ide_exit(s); + } + } + g_free(s->dev); }