[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 080/108] usb: Fix usb-bt-dongle initialization.
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 080/108] usb: Fix usb-bt-dongle initialization. |
Date: |
Wed, 6 Aug 2014 15:39:30 -0500 |
From: Hani Benhabiles <address@hidden>
Due to an incomplete initialization, adding a usb-bt-dongle device through HMP
or QMP will cause a segmentation fault.
Signed-off-by: Hani Benhabiles <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
Signed-off-by: Gerd Hoffmann <address@hidden>
(cherry picked from commit c340a284f382a5f40774521f41b4bade76ddfa58)
Signed-off-by: Michael Roth <address@hidden>
---
hw/usb/dev-bluetooth.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/hw/usb/dev-bluetooth.c b/hw/usb/dev-bluetooth.c
index a9661d2..a76e581 100644
--- a/hw/usb/dev-bluetooth.c
+++ b/hw/usb/dev-bluetooth.c
@@ -19,6 +19,7 @@
*/
#include "qemu-common.h"
+#include "qemu/error-report.h"
#include "hw/usb.h"
#include "hw/usb/desc.h"
#include "sysemu/bt.h"
@@ -506,6 +507,14 @@ static int usb_bt_initfn(USBDevice *dev)
usb_desc_create_serial(dev);
usb_desc_init(dev);
+ s->dev.opaque = s;
+ if (!s->hci) {
+ s->hci = bt_new_hci(qemu_find_bt_vlan(0));
+ }
+ s->hci->opaque = s;
+ s->hci->evt_recv = usb_bt_out_hci_packet_event;
+ s->hci->acl_recv = usb_bt_out_hci_packet_acl;
+ usb_bt_handle_reset(&s->dev);
s->intr = usb_ep_get(dev, USB_TOKEN_IN, USB_EVT_EP);
return 0;
@@ -516,6 +525,7 @@ static USBDevice *usb_bt_init(USBBus *bus, const char
*cmdline)
USBDevice *dev;
struct USBBtState *s;
HCIInfo *hci;
+ const char *name = "usb-bt-dongle";
if (*cmdline) {
hci = hci_init(cmdline);
@@ -525,19 +535,17 @@ static USBDevice *usb_bt_init(USBBus *bus, const char
*cmdline)
if (!hci)
return NULL;
- dev = usb_create_simple(bus, "usb-bt-dongle");
+ dev = usb_create(bus, name);
if (!dev) {
+ error_report("Failed to create USB device '%s'", name);
return NULL;
}
s = DO_UPCAST(struct USBBtState, dev, dev);
- s->dev.opaque = s;
-
s->hci = hci;
- s->hci->opaque = s;
- s->hci->evt_recv = usb_bt_out_hci_packet_event;
- s->hci->acl_recv = usb_bt_out_hci_packet_acl;
-
- usb_bt_handle_reset(&s->dev);
+ if (qdev_init(&dev->qdev) < 0) {
+ error_report("Failed to initialize USB device '%s'", name);
+ return NULL;
+ }
return dev;
}
--
1.9.1
- [Qemu-devel] [PATCH 070/108] migration: remove duplicate code, (continued)
- [Qemu-devel] [PATCH 070/108] migration: remove duplicate code, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 069/108] qga: Fix handle fd leak in acquire_privilege(), Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 071/108] arch_init: Be sure of only one exit entry with DPRINTF() for ram_load(), Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 072/108] migration: catch unknown flags in ram_load, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 073/108] rdma: bug fixes, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 075/108] qdev: reorganize error reporting in bus_set_realized, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 076/108] qdev: recursively unrealize devices when unrealizing bus, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 078/108] vhost: fix resource leak in error handling, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 077/108] scsi-disk: fix bug in scsi_block_new_request() introduced by commit 137745c, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 079/108] virtio-scsi: define dummy handle_output for vhost-scsi vqs, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 080/108] usb: Fix usb-bt-dongle initialization.,
Michael Roth <=
- [Qemu-devel] [PATCH 083/108] coroutine-win32.c: Add noinline attribute to work around gcc bug, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 086/108] target-i386: Filter FEAT_7_0_EBX TCG features too, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 082/108] q35: Use PC_Q35_COMPAT_1_4 on pc-q35-1.4 compat_props, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 084/108] hw/xtensa/xtfpga: fix FLASH mapping to boot region for KC705, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 085/108] target-i386: Make TCG feature filtering more readable, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 088/108] virtio-serial: don't migrate the config space, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 087/108] virtio-net: byteswap virtio-net header, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 089/108] nbd: Don't export a block device with no medium., Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 074/108] hw: Consistently name Error ** objects errp, and not err, Michael Roth, 2014/08/06
- [Qemu-devel] [PATCH 090/108] nbd: Don't validate from and len in NBD_CMD_DISC., Michael Roth, 2014/08/06