On Thu, 7 Oct 2004, Manuel Odendahl wrote:
> Here is the new patch.
I forgot to attach the file, sorry.
Manuel
--- devio-old.c Thu Oct 7 14:27:00 2004
+++ devio.c Thu Oct 7 14:23:28 2004
@@ -19,7 +19,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: devio.c,v 1.7 2000/02/01 17:28:48 fliegl Exp $
+ * $Id: devio.c 827 2004-10-07 07:55:17Z manuel $
*
* This file implements the usbdevfs/x/y files, where
* x is the bus number and y the device number.
@@ -594,10 +594,10 @@
{
struct usb_device *dev = ps->dev;
struct usbdevfs_bulktransfer bulk;
- unsigned int tmo, len1, pipe;
- int len2;
- unsigned char *tbuf;
- int i, ret;
+ unsigned char *tbuf = NULL;
+ unsigned int tmo;
+ unsigned int len1, pipe, len2;
+ int ret, i;
if (copy_from_user(&bulk, (void *)arg, sizeof(bulk)))
return -EFAULT;
@@ -605,43 +605,40 @@
return ret;
if ((ret = checkintf(ps, ret)))
return ret;
+
+ len1 = bulk.len;
if (bulk.ep & USB_DIR_IN)
pipe = usb_rcvbulkpipe(dev, bulk.ep & 0x7f);
else
pipe = usb_sndbulkpipe(dev, bulk.ep & 0x7f);
- if (!usb_maxpacket(dev, pipe, !(bulk.ep & USB_DIR_IN)))
- return -EINVAL;
- len1 = bulk.len;
- if (len1 > PAGE_SIZE)
- return -EINVAL;
- if (!(tbuf = (unsigned char *)__get_free_page(GFP_KERNEL)))
+ if (!(tbuf = kmalloc(len1, GFP_KERNEL)))
return -ENOMEM;
tmo = (bulk.timeout * HZ + 999) / 1000;
if (bulk.ep & 0x80) {
if (len1 && !access_ok(VERIFY_WRITE, bulk.data, len1)) {
- free_page((unsigned long)tbuf);
+ kfree(tbuf);
return -EINVAL;
}
i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo);
if (!i && len2) {
if (copy_to_user(bulk.data, tbuf, len2)) {
- free_page((unsigned long)tbuf);
+ kfree(tbuf);
return -EFAULT;
}
}
} else {
if (len1) {
if (copy_from_user(tbuf, bulk.data, len1)) {
- free_page((unsigned long)tbuf);
+ kfree(tbuf);
return -EFAULT;
}
}
i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo);
}
- free_page((unsigned long)tbuf);
+ kfree(tbuf);
if (i < 0) {
- printk(KERN_WARNING "usbdevfs: USBDEVFS_BULK failed dev %d ep 0x%x len
%u ret %d\n",
- dev->devnum, bulk.ep, bulk.len, i);
+ printk(KERN_WARNING "usbfs: USBDEVFS_BULK failed dev %d "
+ "ep 0x%x len %u ret %d\n", dev->devnum, bulk.ep, bulk.len, i);
return i;
}
return len2;