From patchwork Tue Nov 29 10:33:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9451429 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 774FC6071E for ; Tue, 29 Nov 2016 10:34:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E5FF27F0B for ; Tue, 29 Nov 2016 10:34:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8356427F80; Tue, 29 Nov 2016 10:34:58 +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 BE50F27F0B for ; Tue, 29 Nov 2016 10:34:56 +0000 (UTC) Received: from localhost ([::1]:35911 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBfkV-0007Zd-Bx for patchwork-qemu-devel@patchwork.kernel.org; Tue, 29 Nov 2016 05:34:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBfjw-0007W0-8v for qemu-devel@nongnu.org; Tue, 29 Nov 2016 05:34:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBfjs-0006sj-0M for qemu-devel@nongnu.org; Tue, 29 Nov 2016 05:34:20 -0500 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:33430) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cBfjr-0006rZ-Qm for qemu-devel@nongnu.org; Tue, 29 Nov 2016 05:34:15 -0500 Received: by mail-qk0-x243.google.com with SMTP id x190so16907542qkb.0 for ; Tue, 29 Nov 2016 02:34:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:to:cc:subject:date; bh=BR7F8pvabM5yqfp0F9FSStJptgtrjM6138AqRVWqBZ8=; b=LmaEeeprXCFGwezMnAq00avfcG4xMv2vyEYtAOgdZg5yjEp+VGhRWM7yZ9pjVxSqTe 2+woC5PGnutJwxt7cwoKt2GnzpPGW2wIaXAfuYQHkmEHvWATRv1qAQxGfQLjOF8ql/T0 ICPVyYLnGlUVIH/nVQbFi9fRbkEQ1kgNSMIN8e+f6mlPJaP1u7+FUinf0XosdBvkbsDk vTwysmQhWOh1DKMkHu6E/U6b4pWoRxwPWXvrMftRRpDPev4SQlskYXq+BU2pFyPhkszu 1wSm/W5gsQ9jK5HN7yPCQh1nbcoonPBavvu/j4gWNqtLizAKTi00IOO8fi4KyYkv+pg0 OyCA== 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=BR7F8pvabM5yqfp0F9FSStJptgtrjM6138AqRVWqBZ8=; b=iXjli/HYkQHbP20+R+OzxH0iUHXjqyGfWnel1ejrlJ96hdR8M5NKNw3/RU+eZED/Yj KPSupw/OFzZGksrz4WiUH9lCS/sVaMqJS1vOjxxtRKW2KH+Gu/+UY/0jeYJL1PAn75M8 etw8FFXgMRzLNoHK9/QLJ8YEtkYiqXQ8NrHkgbPxwxGJVVKltmPh+onenMb3sqA/LEFM D1JjrqiG9UD/xsiERM6Ct7uTpDhZvEUk+L05tg5NWNKx4AjeylsQYPqqrD9IYH8wzp6Q FOhJu39nxaXmfH2k2ANlUyfYQW5aIPK3rknKXK5ING+JC7G0w9eBwVQPXbniEo0Gz8uS 3RyA== X-Gm-Message-State: AKaTC01szHFZXzbKCfr+r8PwtlyJYc3wvUpOPkDHOk6gLi5XjHcDFzhFJeOnlY5XSw6ojA== X-Received: by 10.55.119.2 with SMTP id s2mr23517712qkc.1.1480415654632; Tue, 29 Nov 2016 02:34:14 -0800 (PST) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id s89sm30442917qkl.27.2016.11.29.02.34.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Nov 2016 02:34:14 -0800 (PST) Message-ID: <583d59a6.dcc6370a.3a361.b5d4@mx.google.com> X-Google-Original-Message-ID: <1480415621-18011-1-git-send-email-Qiang(liqiang6-s@360.cn)> From: Li Qiang X-Google-Original-From: Li Qiang(liqiang6-s@360.cn) To: kraxel@redhat.com, qemu-devel@nongnu.org Date: Tue, 29 Nov 2016 02:33:41 -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:400d:c09::243 Subject: [Qemu-devel] [PATCH] audio: ac97: add exit function 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 Currently the ac97 device emulation doesn't have a exit function, hot unplug this device will leak some leak. Add a exit function to avoid this. Signed-off-by: Li Qiang --- hw/audio/ac97.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c index cbd959e..2faed35 100644 --- a/hw/audio/ac97.c +++ b/hw/audio/ac97.c @@ -1387,6 +1387,13 @@ static void ac97_realize(PCIDevice *dev, Error **errp) ac97_on_reset (&s->dev.qdev); } +static void ac97_exit(PCIDevice *dev) +{ + AC97LinkState *s = DO_UPCAST(AC97LinkState, dev, dev); + + AUD_remove_card(&s->card); +} + static int ac97_init (PCIBus *bus) { pci_create_simple (bus, -1, "AC97"); @@ -1404,6 +1411,7 @@ static void ac97_class_init (ObjectClass *klass, void *data) PCIDeviceClass *k = PCI_DEVICE_CLASS (klass); k->realize = ac97_realize; + k->exit = ac97_exit; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_82801AA_5; k->revision = 0x01;