[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/7] usb: fix usb_qdev_init error handling.
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 2/7] usb: fix usb_qdev_init error handling. |
Date: |
Wed, 23 Nov 2011 18:25:12 +0100 |
qdev doesn't call the ->exit callback on ->init failures, so we have to
take care ourself that we cleanup property on errors.
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/usb-bus.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index f8b9807..8cafb76 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -9,6 +9,7 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev,
int indent);
static char *usb_get_dev_path(DeviceState *dev);
static char *usb_get_fw_dev_path(DeviceState *qdev);
+static int usb_qdev_exit(DeviceState *qdev);
static struct BusInfo usb_bus_info = {
.name = "USB",
@@ -75,12 +76,23 @@ static int usb_qdev_init(DeviceState *qdev, DeviceInfo
*base)
dev->auto_attach = 1;
QLIST_INIT(&dev->strings);
rc = usb_claim_port(dev);
- if (rc == 0) {
- rc = dev->info->init(dev);
+ if (rc != 0) {
+ goto err;
}
- if (rc == 0 && dev->auto_attach) {
+ rc = dev->info->init(dev);
+ if (rc != 0) {
+ goto err;
+ }
+ if (dev->auto_attach) {
rc = usb_device_attach(dev);
+ if (rc != 0) {
+ goto err;
+ }
}
+ return 0;
+
+err:
+ usb_qdev_exit(qdev);
return rc;
}
--
1.7.1
- [Qemu-devel] [PULL 1.0] usb fixes, Gerd Hoffmann, 2011/11/23
- [Qemu-devel] [PATCH 3/7] usb-hub: wakeup on detach too., Gerd Hoffmann, 2011/11/23
- [Qemu-devel] [PATCH 5/7] usb-ehci: codestyle fixups, Gerd Hoffmann, 2011/11/23
- [Qemu-devel] [PATCH 7/7] usb-host: add usb_host_do_reset function., Gerd Hoffmann, 2011/11/23
- [Qemu-devel] [PATCH 1/7] usb: make usb_create_simple catch and pass up errors., Gerd Hoffmann, 2011/11/23
- [Qemu-devel] [PATCH 2/7] usb: fix usb_qdev_init error handling.,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 6/7] usb-ehci: add register names, Gerd Hoffmann, 2011/11/23
- [Qemu-devel] [PATCH 4/7] usb-hub: implement reset, Gerd Hoffmann, 2011/11/23
- Re: [Qemu-devel] [PULL 1.0] usb fixes, Anthony Liguori, 2011/11/28