diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-03-23 23:44:19 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-03-23 23:44:19 -0500 |
commit | 1ebbe2b20091d306453a5cf480a87e6cd28ae76f (patch) | |
tree | f5cd7a0fa69b8b1938cb5a0faed2e7b0628072a5 /drivers/usb/core/devio.c | |
parent | ac58c9059da8886b5e8cde012a80266b18ca146e (diff) | |
parent | 674a396c6d2ba0341ebdd7c1c9950f32f018e2dd (diff) |
Merge branch 'linus'
Diffstat (limited to 'drivers/usb/core/devio.c')
-rw-r--r-- | drivers/usb/core/devio.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 2b68998fe4b3..545da37afca7 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -134,26 +134,21 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, l | |||
134 | } | 134 | } |
135 | 135 | ||
136 | if (pos < sizeof(struct usb_device_descriptor)) { | 136 | if (pos < sizeof(struct usb_device_descriptor)) { |
137 | struct usb_device_descriptor *desc = kmalloc(sizeof(*desc), GFP_KERNEL); | 137 | struct usb_device_descriptor temp_desc ; /* 18 bytes - fits on the stack */ |
138 | if (!desc) { | 138 | |
139 | ret = -ENOMEM; | 139 | memcpy(&temp_desc, &dev->descriptor, sizeof(dev->descriptor)); |
140 | goto err; | 140 | le16_to_cpus(&temp_desc.bcdUSB); |
141 | } | 141 | le16_to_cpus(&temp_desc.idVendor); |
142 | memcpy(desc, &dev->descriptor, sizeof(dev->descriptor)); | 142 | le16_to_cpus(&temp_desc.idProduct); |
143 | le16_to_cpus(&desc->bcdUSB); | 143 | le16_to_cpus(&temp_desc.bcdDevice); |
144 | le16_to_cpus(&desc->idVendor); | ||
145 | le16_to_cpus(&desc->idProduct); | ||
146 | le16_to_cpus(&desc->bcdDevice); | ||
147 | 144 | ||
148 | len = sizeof(struct usb_device_descriptor) - pos; | 145 | len = sizeof(struct usb_device_descriptor) - pos; |
149 | if (len > nbytes) | 146 | if (len > nbytes) |
150 | len = nbytes; | 147 | len = nbytes; |
151 | if (copy_to_user(buf, ((char *)desc) + pos, len)) { | 148 | if (copy_to_user(buf, ((char *)&temp_desc) + pos, len)) { |
152 | kfree(desc); | ||
153 | ret = -EFAULT; | 149 | ret = -EFAULT; |
154 | goto err; | 150 | goto err; |
155 | } | 151 | } |
156 | kfree(desc); | ||
157 | 152 | ||
158 | *ppos += len; | 153 | *ppos += len; |
159 | buf += len; | 154 | buf += len; |
@@ -498,7 +493,8 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype, unsig | |||
498 | { | 493 | { |
499 | int ret = 0; | 494 | int ret = 0; |
500 | 495 | ||
501 | if (ps->dev->state != USB_STATE_CONFIGURED) | 496 | if (ps->dev->state != USB_STATE_ADDRESS |
497 | && ps->dev->state != USB_STATE_CONFIGURED) | ||
502 | return -EHOSTUNREACH; | 498 | return -EHOSTUNREACH; |
503 | if (USB_TYPE_VENDOR == (USB_TYPE_MASK & requesttype)) | 499 | if (USB_TYPE_VENDOR == (USB_TYPE_MASK & requesttype)) |
504 | return 0; | 500 | return 0; |