From nobody Mon Feb 9 10:38:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1614692090; cv=none; d=zohomail.com; s=zohoarc; b=GfUa6T7IcZ2E8Zggl8H+6bZM5tWDTCYKjMdp38o4LwPoo3aAnyeN+yMHtYxicizb53QfB+0SD8a/uB2DunmRas6KsRuPuEj+ZEMU+E/yYsTprcPhfWSwNUZ0yOfFdHbtNBjl4r+sPc1XZGjP8p/vf9jgBGEk2FL68A9Y91S40nQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614692090; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=o+C7cISg4dcU6/6r+656l0vjRXPh40c7GtIxJGvSXQ0=; b=mAuINcmG0/e2N9Iipa8QmSrbmqja7drsGUxhVtMwbDi2ChMogBlJdKdw3uvILTeVC++ZnhrjhEsJwYPM33oY7N9S4Xc2BWMWl3Zyoly/CAIE6vgR7DSQ77Dw6TJK0M20jva0pqhd6xvFqqwlPJUlxWtk3C8Q2HhNQ6molQxOwAY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614692090152291.78993787440265; Tue, 2 Mar 2021 05:34:50 -0800 (PST) Received: from localhost ([::1]:50998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lH5An-0002RD-5k for importer@patchew.org; Tue, 02 Mar 2021 08:34:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lH59c-0000jC-JU; Tue, 02 Mar 2021 08:33:37 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:3055) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lH59X-0002Tx-ED; Tue, 02 Mar 2021 08:33:36 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DqdMc0VxszjTHF; Tue, 2 Mar 2021 21:31:56 +0800 (CST) Received: from localhost.localdomain (10.175.104.175) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Tue, 2 Mar 2021 21:33:12 +0800 From: Peng Liang To: Subject: [PATCH] lsilogic: Use PCIDevice::exit instead of DeviceState::unrealize Date: Tue, 2 Mar 2021 21:30:16 +0800 Message-ID: <20210302133016.1221081-1-liangpeng10@huawei.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.32; envelope-from=liangpeng10@huawei.com; helo=szxga06-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, mst@redhat.com, qemu-stable@nongnu.org, xiexiangyou@huawei.com, liangpeng10@huawei.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" PCI_DEVICE has overwritten DeviceState::unrealize (pci_qdev_unrealize). However, LSI53C895A, which is a subclass of PCI_DEVICE, overwrites it again and doesn't save the parent's implementation so the PCI_DEVICE's implementation of DeviceState::unrealize will never be called when unrealize a LSI53C895A device. And it will lead to memory leak and unplug failure. For a PCI device, it's better to implement PCIDevice::exit instead of DeviceState::unrealize. So let's change to use PCIDevice::exit. Fixes: a8632434c7e9 ("lsi: implement I/O memory space for Memory Move instr= uctions") Cc: qemu-stable@nongnu.org Signed-off-by: Peng Liang --- hw/scsi/lsi53c895a.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index 7d13c7dc1c46..af46c62f0d78 100644 --- a/hw/scsi/lsi53c895a.c +++ b/hw/scsi/lsi53c895a.c @@ -2312,7 +2312,7 @@ static void lsi_scsi_realize(PCIDevice *dev, Error **= errp) scsi_bus_new(&s->bus, sizeof(s->bus), d, &lsi_scsi_info, NULL); } =20 -static void lsi_scsi_unrealize(DeviceState *dev) +static void lsi_scsi_exit(PCIDevice *dev) { LSIState *s =3D LSI53C895A(dev); =20 @@ -2325,11 +2325,11 @@ static void lsi_class_init(ObjectClass *klass, void= *data) PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); =20 k->realize =3D lsi_scsi_realize; + k->exit =3D lsi_scsi_exit; k->vendor_id =3D PCI_VENDOR_ID_LSI_LOGIC; k->device_id =3D PCI_DEVICE_ID_LSI_53C895A; k->class_id =3D PCI_CLASS_STORAGE_SCSI; k->subsystem_id =3D 0x1000; - dc->unrealize =3D lsi_scsi_unrealize; dc->reset =3D lsi_scsi_reset; dc->vmsd =3D &vmstate_lsi_scsi; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); --=20 2.29.2