Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 22020
b: refs/heads/master
c: 8781ba0
h: refs/heads/master
v: v3
  • Loading branch information
Oliver Neukum authored and Greg Kroah-Hartman committed Mar 20, 2006
1 parent acc6532 commit 59f0dce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 60f780528f3ae603eb169a221628b93b6c6929f9
refs/heads/master: 8781ba0aa9d9dd2870b75dba8d9a47e0f5a3f96a
21 changes: 8 additions & 13 deletions trunk/drivers/usb/core/devio.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,26 +134,21 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, l
}

if (pos < sizeof(struct usb_device_descriptor)) {
struct usb_device_descriptor *desc = kmalloc(sizeof(*desc), GFP_KERNEL);
if (!desc) {
ret = -ENOMEM;
goto err;
}
memcpy(desc, &dev->descriptor, sizeof(dev->descriptor));
le16_to_cpus(&desc->bcdUSB);
le16_to_cpus(&desc->idVendor);
le16_to_cpus(&desc->idProduct);
le16_to_cpus(&desc->bcdDevice);
struct usb_device_descriptor temp_desc ; /* 18 bytes - fits on the stack */

memcpy(&temp_desc, &dev->descriptor, sizeof(dev->descriptor));
le16_to_cpus(&temp_desc->bcdUSB);
le16_to_cpus(&temp_desc->idVendor);
le16_to_cpus(&temp_desc->idProduct);
le16_to_cpus(&temp_desc->bcdDevice);

len = sizeof(struct usb_device_descriptor) - pos;
if (len > nbytes)
len = nbytes;
if (copy_to_user(buf, ((char *)desc) + pos, len)) {
kfree(desc);
if (copy_to_user(buf, ((char *)&temp_desc) + pos, len)) {
ret = -EFAULT;
goto err;
}
kfree(desc);

*ppos += len;
buf += len;
Expand Down

0 comments on commit 59f0dce

Please sign in to comment.