[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 04/14] usb: host-linux: Ignore parsing errors of the
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 04/14] usb: host-linux: Ignore parsing errors of the device descriptors |
Date: |
Fri, 16 Nov 2012 14:44:37 +0100 |
From: Jan Kiszka <address@hidden>
The Linux is more tolerant here as well: Just stop parsing the device
descriptors when an error is detected but do not reset what was found
so far. This allows to run buggy devices with partially invalid
descriptors.
Signed-off-by: Jan Kiszka <address@hidden>
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/usb/host-linux.c | 31 +++++++++++--------------------
1 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/hw/usb/host-linux.c b/hw/usb/host-linux.c
index 5bc77b2..b17e1dc 100644
--- a/hw/usb/host-linux.c
+++ b/hw/usb/host-linux.c
@@ -135,7 +135,7 @@ static int parse_filter(const char *spec, struct
USBAutoFilter *f);
static void usb_host_auto_check(void *unused);
static int usb_host_read_file(char *line, size_t line_size,
const char *device_file, const char *device_name);
-static int usb_linux_update_endp_table(USBHostDevice *s);
+static void usb_linux_update_endp_table(USBHostDevice *s);
static int usb_host_usbfs_type(USBHostDevice *s, USBPacket *p)
{
@@ -1132,8 +1132,7 @@ static void usb_host_handle_control(USBDevice *dev,
USBPacket *p,
p->status = USB_RET_ASYNC;
}
-/* returns 1 on problem encountered or 0 for success */
-static int usb_linux_update_endp_table(USBHostDevice *s)
+static void usb_linux_update_endp_table(USBHostDevice *s)
{
static const char *tname[] = {
[USB_ENDPOINT_XFER_CONTROL] = "control",
@@ -1159,23 +1158,23 @@ static int usb_linux_update_endp_table(USBHostDevice *s)
if (d->bLength < 2) {
trace_usb_host_parse_error(s->bus_num, s->addr,
"descriptor too short");
- goto error;
+ return;
}
if (i + d->bLength > s->descr_len) {
trace_usb_host_parse_error(s->bus_num, s->addr,
"descriptor too long");
- goto error;
+ return;
}
switch (d->bDescriptorType) {
case 0:
trace_usb_host_parse_error(s->bus_num, s->addr,
"invalid descriptor type");
- goto error;
+ return;
case USB_DT_DEVICE:
if (d->bLength < 0x12) {
trace_usb_host_parse_error(s->bus_num, s->addr,
"device descriptor too short");
- goto error;
+ return;
}
v = (d->u.device.idVendor_hi << 8) | d->u.device.idVendor_lo;
p = (d->u.device.idProduct_hi << 8) | d->u.device.idProduct_lo;
@@ -1185,7 +1184,7 @@ static int usb_linux_update_endp_table(USBHostDevice *s)
if (d->bLength < 0x09) {
trace_usb_host_parse_error(s->bus_num, s->addr,
"config descriptor too short");
- goto error;
+ return;
}
configuration = d->u.config.bConfigurationValue;
active = (configuration == s->dev.configuration);
@@ -1196,7 +1195,7 @@ static int usb_linux_update_endp_table(USBHostDevice *s)
if (d->bLength < 0x09) {
trace_usb_host_parse_error(s->bus_num, s->addr,
"interface descriptor too short");
- goto error;
+ return;
}
interface = d->u.interface.bInterfaceNumber;
altsetting = d->u.interface.bAlternateSetting;
@@ -1209,7 +1208,7 @@ static int usb_linux_update_endp_table(USBHostDevice *s)
if (d->bLength < 0x07) {
trace_usb_host_parse_error(s->bus_num, s->addr,
"endpoint descriptor too short");
- goto error;
+ return;
}
devep = d->u.endpoint.bEndpointAddress;
pid = (devep & USB_DIR_IN) ? USB_TOKEN_IN : USB_TOKEN_OUT;
@@ -1217,7 +1216,7 @@ static int usb_linux_update_endp_table(USBHostDevice *s)
if (ep == 0) {
trace_usb_host_parse_error(s->bus_num, s->addr,
"invalid endpoint address");
- goto error;
+ return;
}
type = d->u.endpoint.bmAttributes & 0x3;
@@ -1250,11 +1249,6 @@ static int usb_linux_update_endp_table(USBHostDevice *s)
break;
}
}
- return 0;
-
-error:
- usb_ep_reset(&s->dev);
- return 1;
}
/*
@@ -1341,10 +1335,7 @@ static int usb_host_open(USBHostDevice *dev, int bus_num,
}
usb_ep_init(&dev->dev);
- ret = usb_linux_update_endp_table(dev);
- if (ret) {
- goto fail;
- }
+ usb_linux_update_endp_table(dev);
if (speed == -1) {
struct usbdevfs_connectinfo ci;
--
1.7.1
- [Qemu-devel] [PATCH 03/14] usb-host: scan for usb devices when the vm starts, (continued)
- [Qemu-devel] [PATCH 03/14] usb-host: scan for usb devices when the vm starts, Gerd Hoffmann, 2012/11/16
- [Qemu-devel] [PATCH 01/14] fix live migration, Gerd Hoffmann, 2012/11/16
- [Qemu-devel] [PATCH 06/14] ehci: Fixup q->qtdaddr after cancelling an already completed packet, Gerd Hoffmann, 2012/11/16
- [Qemu-devel] [PATCH 05/14] ehci: Don't access packet after freeing it, Gerd Hoffmann, 2012/11/16
- [Qemu-devel] [PATCH 09/14] ehci: keep the frame timer running in case the guest asked for frame list rollover interrupts, Gerd Hoffmann, 2012/11/16
- [Qemu-devel] [PATCH 07/14] ehci: Better detection for qtd-s linked in circles, Gerd Hoffmann, 2012/11/16
- [Qemu-devel] [PATCH 12/14] usb-redir: Set default debug level to warning, Gerd Hoffmann, 2012/11/16
- [Qemu-devel] [PATCH 13/14] usb-host: update tracing, Gerd Hoffmann, 2012/11/16
- [Qemu-devel] [PATCH 11/14] usb-redir: Only add actually in flight packets to the in flight queue, Gerd Hoffmann, 2012/11/16
- [Qemu-devel] [PATCH 14/14] usb-host: fix splitted transfers, Gerd Hoffmann, 2012/11/16
- [Qemu-devel] [PATCH 04/14] usb: host-linux: Ignore parsing errors of the device descriptors,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 10/14] ehci: handle dma errors, Gerd Hoffmann, 2012/11/16
- [Qemu-devel] [PATCH 02/14] usb: Fix (another) bug in usb_packet_map() for IOMMU handling, Gerd Hoffmann, 2012/11/16
- [Qemu-devel] [PATCH 08/14] ehci: Don't verify the next pointer for periodic qh-s and qtd-s, Gerd Hoffmann, 2012/11/16