From patchwork Wed Nov 23 09:35:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prasad Pandit X-Patchwork-Id: 698120 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 3tNxzn2rSpz9t0v for ; Wed, 23 Nov 2016 20:36:21 +1100 (AEDT) Received: from localhost ([::1]:60447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9TyU-0000EJ-Pu for incoming@patchwork.ozlabs.org; Wed, 23 Nov 2016 04:36:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9TxT-00086j-1E for qemu-devel@nongnu.org; Wed, 23 Nov 2016 04:35:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9TxP-0002fl-TD for qemu-devel@nongnu.org; Wed, 23 Nov 2016 04:35:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36836) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c9TxP-0002c7-Ly for qemu-devel@nongnu.org; Wed, 23 Nov 2016 04:35:11 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A6C9D624B8; Wed, 23 Nov 2016 09:35:07 +0000 (UTC) Received: from javelin.localdomain (vpn-54-226.rdu2.redhat.com [10.10.54.226]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAN9Z2iS027146 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 23 Nov 2016 04:35:05 -0500 From: P J P To: Qemu Developers Date: Wed, 23 Nov 2016 15:05:00 +0530 Message-Id: <1479893700-4596-1-git-send-email-ppandit@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 23 Nov 2016 09:35:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] audio: es1370: unregister reset call on 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: Huawei PSIRT , Gerd Hoffmann , Prasad J Pandit Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Prasad J Pandit ES1370 audio device emulator registers a device reset call with Qemu during initialisation. But the same is not unregistered when audio device is unplugged. This leads to a use-after-free error during reboot, as Qemu resets the machine. Add 'es1370_exit' PCIDeviceClass method to avoid it. Reported-by: Huawei PSIRT Signed-off-by: Prasad J Pandit --- hw/audio/es1370.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index 8449b5f..5c97295 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -1047,12 +1047,19 @@ static int es1370_init (PCIBus *bus) return 0; } +static void es1370_exit (PCIDevice *dev) +{ + ES1370State *s = ES1370(dev); + qemu_unregister_reset(es1370_on_reset, s); +} + static void es1370_class_init (ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS (klass); PCIDeviceClass *k = PCI_DEVICE_CLASS (klass); k->realize = es1370_realize; + k->exit = es1370_exit; k->vendor_id = PCI_VENDOR_ID_ENSONIQ; k->device_id = PCI_DEVICE_ID_ENSONIQ_ES1370; k->class_id = PCI_CLASS_MULTIMEDIA_AUDIO;