Commit a64c6e4b authored by Chris Hanson's avatar Chris Hanson Committed by Greg Kroah-Hartman

[PATCH] page limit on bulk transfers in usbfs?

Here is an updated patch using kmalloc that removes the page limit
on bulk transfers in usbfs.  I've tested it and it seems to work OK.
parent 06165e7d
...@@ -597,33 +597,31 @@ static int proc_bulk(struct dev_state *ps, void *arg) ...@@ -597,33 +597,31 @@ static int proc_bulk(struct dev_state *ps, void *arg)
if (!usb_maxpacket(dev, pipe, !(bulk.ep & USB_DIR_IN))) if (!usb_maxpacket(dev, pipe, !(bulk.ep & USB_DIR_IN)))
return -EINVAL; return -EINVAL;
len1 = bulk.len; len1 = bulk.len;
if (len1 > PAGE_SIZE) if (!(tbuf = kmalloc(len1, GFP_KERNEL)))
return -EINVAL;
if (!(tbuf = (unsigned char *)__get_free_page(GFP_KERNEL)))
return -ENOMEM; return -ENOMEM;
tmo = (bulk.timeout * HZ + 999) / 1000; tmo = (bulk.timeout * HZ + 999) / 1000;
if (bulk.ep & 0x80) { if (bulk.ep & 0x80) {
if (len1 && !access_ok(VERIFY_WRITE, bulk.data, len1)) { if (len1 && !access_ok(VERIFY_WRITE, bulk.data, len1)) {
free_page((unsigned long)tbuf); kfree(tbuf);
return -EINVAL; return -EINVAL;
} }
i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo); i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo);
if (!i && len2) { if (!i && len2) {
if (copy_to_user(bulk.data, tbuf, len2)) { if (copy_to_user(bulk.data, tbuf, len2)) {
free_page((unsigned long)tbuf); kfree(tbuf);
return -EFAULT; return -EFAULT;
} }
} }
} else { } else {
if (len1) { if (len1) {
if (copy_from_user(tbuf, bulk.data, len1)) { if (copy_from_user(tbuf, bulk.data, len1)) {
free_page((unsigned long)tbuf); kfree(tbuf);
return -EFAULT; return -EFAULT;
} }
} }
i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo); i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo);
} }
free_page((unsigned long)tbuf); kfree(tbuf);
if (i < 0) { if (i < 0) {
printk(KERN_WARNING "usbfs: USBDEVFS_BULK failed dev %d ep 0x%x len %u ret %d\n", printk(KERN_WARNING "usbfs: USBDEVFS_BULK failed dev %d ep 0x%x len %u ret %d\n",
dev->devnum, bulk.ep, bulk.len, i); dev->devnum, bulk.ep, bulk.len, i);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment