]> git.proxmox.com Git - qemu.git/commitdiff
usb-hub: need to check dev->attached
authorGerd Hoffmann <kraxel@redhat.com>
Thu, 15 Sep 2011 07:20:02 +0000 (09:20 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Thu, 13 Oct 2011 10:58:51 +0000 (12:58 +0200)
commit 891fb2cd4592b6fe76106a69e0ca40efbf82726a did that for all host
controllers, the usb hub was left out by accident.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb-hub.c

index 286e3ad85dc7cccb69496bcffd660f978ce63c1c..39382c738630614b3894c8a867870b2242db5388 100644 (file)
@@ -289,7 +289,7 @@ static int usb_hub_handle_control(USBDevice *dev, USBPacket *p,
                 port->wPortStatus |= PORT_STAT_SUSPEND;
                 break;
             case PORT_RESET:
-                if (dev) {
+                if (dev && dev->attached) {
                     usb_send_msg(dev, USB_MSG_RESET);
                     port->wPortChange |= PORT_STAT_C_RESET;
                     /* set enable bit */
@@ -429,7 +429,7 @@ static int usb_hub_broadcast_packet(USBHubState *s, USBPacket *p)
     for(i = 0; i < NUM_PORTS; i++) {
         port = &s->ports[i];
         dev = port->port.dev;
-        if (dev && (port->wPortStatus & PORT_STAT_ENABLE)) {
+        if (dev && dev->attached && (port->wPortStatus & PORT_STAT_ENABLE)) {
             ret = usb_handle_packet(dev, p);
             if (ret != USB_RET_NODEV) {
                 return ret;