]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
USB: Do not pass negative length to snoop_urb()
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 15 Mar 2011 15:41:47 +0000 (16:41 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sun, 27 Mar 2011 19:00:25 +0000 (12:00 -0700)
commit 9d02b42614149ebccf12c9c580601ed01bd83070 upstream.

When `echo Y > /sys/module/usbcore/parameters/usbfs_snoop` and
usb_control_msg() returns error, a lot of kernel memory is dumped to dmesg
until unhandled kernel paging request occurs.

Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/devio.c

index a7131ad630f9ad54535205017352ee10175df384..37518dfdeb987188089eb43c3147417ce14615a9 100644 (file)
@@ -802,7 +802,7 @@ static int proc_control(struct dev_state *ps, void __user *arg)
                                    tbuf, ctrl.wLength, tmo);
                usb_lock_device(dev);
                snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE,
-                       tbuf, i);
+                         tbuf, max(i, 0));
                if ((i > 0) && ctrl.wLength) {
                        if (copy_to_user(ctrl.data, tbuf, i)) {
                                free_page((unsigned long)tbuf);