Received: from [140.186.70.92] (port=54041 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OR1vE-0007qx-Vi for qemu-devel@nongnu.org; Tue, 22 Jun 2010 07:45:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OR1vC-0006rk-Tg for qemu-devel@nongnu.org; Tue, 22 Jun 2010 07:45:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64843) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OR1vC-0006rD-Lu for qemu-devel@nongnu.org; Tue, 22 Jun 2010 07:45:42 -0400 Date: Tue, 22 Jun 2010 14:40:43 +0300 From: "Michael S. Tsirkin" Message-ID: <20100622114043.GB17231@redhat.com> References: <4c318ce68b597bd8cec2215bfc969a1cd0e2b136.1277174072.git.yamahata@valinux.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4c318ce68b597bd8cec2215bfc969a1cd0e2b136.1277174072.git.yamahata@valinux.co.jp> Subject: [Qemu-devel] Re: [PATCH v2 3/3] pci hotplug: make pci hotplug return value to caller. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Isaku Yamahata Cc: qemu-devel@nongnu.org, kraxel@redhat.com On Tue, Jun 22, 2010 at 11:55:35AM +0900, Isaku Yamahata wrote: > make pci hotplug callback return value to caller. > And when returning error, allocated resources are freed. > > Signed-off-by: Isaku Yamahata > --- > hw/pci.c | 15 +++++++++++---- > 1 files changed, 11 insertions(+), 4 deletions(-) > > diff --git a/hw/pci.c b/hw/pci.c > index 75acbd3..76418c5 100644 > --- a/hw/pci.c > +++ b/hw/pci.c > @@ -1626,8 +1626,16 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) > pci_dev->romfile = qemu_strdup(info->romfile); > pci_add_option_rom(pci_dev); > > - if (qdev->hotplugged) > - bus->hotplug(bus->hotplug_qdev, pci_dev, 1); > + if (qdev->hotplugged) { > + rc = bus->hotplug(bus->hotplug_qdev, pci_dev, 1); > + if (rc != 0) { > + int rc1 = pci_unregister_device(&pci_dev->qdev); > + if (rc1) { > + error_report("pci_unregister_device failed in pci_qdev_init.\n"); > + } This should be assert. > + return rc; > + } > + } > return 0; > } > > @@ -1635,8 +1643,7 @@ static int pci_unplug_device(DeviceState *qdev) > { > PCIDevice *dev = DO_UPCAST(PCIDevice, qdev, qdev); > > - dev->bus->hotplug(dev->bus->hotplug_qdev, dev, 0); > - return 0; > + return dev->bus->hotplug(dev->bus->hotplug_qdev, dev, 0); > } > > void pci_qdev_register(PCIDeviceInfo *info) > -- > 1.6.6.1