Changeset
hw/core/bus.c                 |  1 +
hw/usb/dev-smartcard-reader.c |  1 -
hw/usb/dev-storage.c          | 16 ----------------
hw/usb/dev-uas.c              |  2 --
4 files changed, 1 insertion(+), 19 deletions(-)
Git apply log
Switched to a new branch '20180613172815.32738-1-marcandre.lureau@redhat.com'
Applying: Revert "usb-ccid: fix bus leak"
Applying: Revert "usb: release the created buses"
Applying: Revert "bus: do not unref the added child bus on realize"
To https://github.com/patchew-project/qemu
 * [new tag]         patchew/20180613172815.32738-1-marcandre.lureau@redhat.com -> patchew/20180613172815.32738-1-marcandre.lureau@redhat.com
Test passed: checkpatch

loading

Test passed: docker-mingw@fedora

loading

Test passed: docker-quick@centos7

loading

Test passed: s390x

loading

[Qemu-devel] [PATCH 0/3] Fix usb-ccid hotplug regression follow-up
Posted by Marc-André Lureau, 1 week ago
Hi,

The series "[Qemu-devel] [PATCH 0/4] Fix usb-ccid hotplug regression"
made wrong assumptions about bus ref'counting pointed out by Paolo
after it was merged.

This series reverts the 2 offending patches, as well as a older
related patch that is now clearly wrong as well.

Marc-André Lureau (3):
  Revert "usb-ccid: fix bus leak"
  Revert "usb: release the created buses"
  Revert "bus: do not unref the added child bus on realize"

 hw/core/bus.c                 |  1 +
 hw/usb/dev-smartcard-reader.c |  1 -
 hw/usb/dev-storage.c          | 16 ----------------
 hw/usb/dev-uas.c              |  2 --
 4 files changed, 1 insertion(+), 19 deletions(-)

-- 
2.18.0.rc1


[Qemu-devel] [PATCH 1/3] Revert "usb-ccid: fix bus leak"
Posted by Marc-André Lureau, 1 week ago
The bus is not owned by the device.

This reverts commit 410a096adf991ce437d4d7dabc59b6557e6d488d.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/usb/dev-smartcard-reader.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index f7c91230d5..2131e33d27 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -1147,7 +1147,6 @@ static void ccid_unrealize(USBDevice *dev, Error **errp)
     USBCCIDState *s = USB_CCID_DEV(dev);
 
     ccid_bulk_in_clear(s);
-    object_unref(OBJECT(&s->bus));
 }
 
 static void ccid_flush_pending_answers(USBCCIDState *s)
-- 
2.18.0.rc1


[Qemu-devel] [PATCH 2/3] Revert "usb: release the created buses"
Posted by Marc-André Lureau, 1 week ago
The USB device don't hold the bus. There is no ASAN related reports
anymore.

This reverts commit cd7bc87868d534f95e928cad98e2a52df7695771.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/usb/dev-storage.c | 16 ----------------
 hw/usb/dev-uas.c     |  2 --
 2 files changed, 18 deletions(-)

diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index 481694a473..d44f01a97e 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -588,13 +588,6 @@ static const struct SCSIBusInfo usb_msd_scsi_info_bot = {
     .load_request = usb_msd_load_request,
 };
 
-static void usb_msd_unrealize_storage(USBDevice *dev, Error **errp)
-{
-    MSDState *s = USB_STORAGE_DEV(dev);
-
-    object_unref(OBJECT(&s->bus));
-}
-
 static void usb_msd_storage_realize(USBDevice *dev, Error **errp)
 {
     MSDState *s = USB_STORAGE_DEV(dev);
@@ -643,13 +636,6 @@ static void usb_msd_storage_realize(USBDevice *dev, Error **errp)
     s->scsi_dev = scsi_dev;
 }
 
-static void usb_msd_bot_unrealize(USBDevice *dev, Error **errp)
-{
-    MSDState *s = USB_STORAGE_DEV(dev);
-
-    object_unref(OBJECT(&s->bus));
-}
-
 static void usb_msd_bot_realize(USBDevice *dev, Error **errp)
 {
     MSDState *s = USB_STORAGE_DEV(dev);
@@ -713,7 +699,6 @@ static void usb_msd_class_storage_initfn(ObjectClass *klass, void *data)
     USBDeviceClass *uc = USB_DEVICE_CLASS(klass);
 
     uc->realize = usb_msd_storage_realize;
-    uc->unrealize = usb_msd_unrealize_storage;
     dc->props = msd_properties;
 }
 
@@ -776,7 +761,6 @@ static void usb_msd_class_bot_initfn(ObjectClass *klass, void *data)
     USBDeviceClass *uc = USB_DEVICE_CLASS(klass);
 
     uc->realize = usb_msd_bot_realize;
-    uc->unrealize = usb_msd_bot_unrealize;
     uc->attached_settable = true;
 }
 
diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c
index aaf5a88095..be566cad02 100644
--- a/hw/usb/dev-uas.c
+++ b/hw/usb/dev-uas.c
@@ -896,8 +896,6 @@ static void usb_uas_unrealize(USBDevice *dev, Error **errp)
     UASDevice *uas = USB_UAS(dev);
 
     qemu_bh_delete(uas->status_bh);
-
-    object_unref(OBJECT(&uas->bus));
 }
 
 static void usb_uas_realize(USBDevice *dev, Error **errp)
-- 
2.18.0.rc1


[Qemu-devel] [PATCH 3/3] Revert "bus: do not unref the added child bus on realize"
Posted by Marc-André Lureau, 1 week ago
This is wrong.  object_finalize_child_property()'s unref balances the
ref in object_property_add_child().  qbus_realize's unref balances the
ref that was initially placed by object_new/object_initialize.

This reverts commit f3d58385a6d3d82f65db602c5506e2d3d8c82394.

Reported-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/core/bus.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/core/bus.c b/hw/core/bus.c
index ad0c9df335..4651f24486 100644
--- a/hw/core/bus.c
+++ b/hw/core/bus.c
@@ -102,6 +102,7 @@ static void qbus_realize(BusState *bus, DeviceState *parent, const char *name)
         QLIST_INSERT_HEAD(&bus->parent->child_bus, bus, sibling);
         bus->parent->num_child_bus++;
         object_property_add_child(OBJECT(bus->parent), bus->name, OBJECT(bus), NULL);
+        object_unref(OBJECT(bus));
     } else if (bus != sysbus_get_default()) {
         /* TODO: once all bus devices are qdevified,
            only reset handler for main_system_bus should be registered here. */
-- 
2.18.0.rc1