From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bk6Gh-0000Y0-V2 for qemu-devel@nongnu.org; Wed, 14 Sep 2016 05:14:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bk6Gd-0003bm-Qt for qemu-devel@nongnu.org; Wed, 14 Sep 2016 05:14:11 -0400 Received: from [59.151.112.132] (port=12988 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bk6Gd-0003aC-EL for qemu-devel@nongnu.org; Wed, 14 Sep 2016 05:14:07 -0400 From: Cao jin Date: Wed, 14 Sep 2016 17:14:26 +0800 Message-ID: <1473844466-17458-1-git-send-email-caoj.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH RFC] pci: call PCIDeviceClass->exit on its .realize failure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Marcel Apfelbaum It cannot guarantee all pci devices will free the allocated resource in its .realize function on realize failure. CC: Michael S. Tsirkin CC: Marcel Apfelbaum Signed-off-by: Cao jin --- I found not all the devices will free the allocated resources on .realize failure, and .exit function is the one who take responsibility to free all the resource. In theory, I think it should be PCIDeviceClass->exit who does the cleanup on realize failure, with appropriate check whether certain resources is allocated. It passed make check, but maybe need more confirmation, so, RFC. hw/pci/pci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 24fae16..4b63a79 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1967,6 +1967,9 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp) if (local_err) { error_propagate(errp, local_err); do_pci_unregister_device(pci_dev); + if (pc->exit) { + pc->exit(pci_dev); + } return; } } -- 2.1.0