]> git.proxmox.com Git - qemu.git/blobdiff - usb-linux.c
net: Warn about "-net nic" options which were ignored
[qemu.git] / usb-linux.c
index feb4d36d0bef320c12a5e3824b82b8b09dd6e2f0..5d2ec5c5c7034cb130719e5c277bd2140c23939d 100644 (file)
@@ -115,7 +115,7 @@ typedef struct USBHostDevice {
     USBDevice dev;
     int       fd;
 
-    uint8_t   descr[1024];
+    uint8_t   descr[8192];
     int       descr_len;
     int       configuration;
     int       ninterfaces;
@@ -1029,6 +1029,11 @@ static int usb_linux_update_endp_table(USBHostDevice *s)
             }
 
             devep = descriptors[i + 2];
+            if ((devep & 0x0f) == 0) {
+                fprintf(stderr, "usb-linux: invalid ep descriptor, ep == 0\n");
+                return 1;
+            }
+
             switch (descriptors[i + 3] & 0x3) {
             case 0x00:
                 type = USBDEVFS_URB_TYPE_CONTROL;
@@ -1153,9 +1158,9 @@ static int usb_host_open(USBHostDevice *dev, int bus_num,
     return 0;
 
 fail:
-    dev->fd = -1;
-    if (fd != -1) {
-        close(fd);
+    if (dev->fd != -1) {
+        close(dev->fd);
+        dev->fd = -1;
     }
     return -1;
 }
@@ -1164,7 +1169,7 @@ static int usb_host_close(USBHostDevice *dev)
 {
     int i;
 
-    if (dev->fd == -1) {
+    if (dev->fd == -1 || !dev->dev.attached) {
         return -1;
     }
 
@@ -1666,6 +1671,7 @@ static int usb_host_auto_scan(void *opaque, int bus_num, int addr, char *port,
         DPRINTF("husb: auto open: bus_num %d addr %d\n", bus_num, addr);
 
         usb_host_open(s, bus_num, addr, port, product_name, speed);
+        break;
     }
 
     return 0;