summaryrefslogtreecommitdiffstats
path: root/drivers/usb/misc/usbtest.c
diff options
context:
space:
mode:
authorDan Carpenter2012-11-17 16:06:11 +0100
committerGreg Kroah-Hartman2012-11-21 22:32:26 +0100
commit564e69893c63cefe4bcbdeda4f940bf68b6b4491 (patch)
treed7563b2a16afe3f6d0afcfd290e6b1c6a3650d05 /drivers/usb/misc/usbtest.c
parentusb: remove use of __devexit (diff)
downloadkernel-qcow2-linux-564e69893c63cefe4bcbdeda4f940bf68b6b4491.tar.gz
kernel-qcow2-linux-564e69893c63cefe4bcbdeda4f940bf68b6b4491.tar.xz
kernel-qcow2-linux-564e69893c63cefe4bcbdeda4f940bf68b6b4491.zip
USB: usbtest: prevent a divide by zero bug
If param->length is zero, then this could lead to a divide by zero bug later in the function when we do: size %= max; Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/misc/usbtest.c')
-rw-r--r--drivers/usb/misc/usbtest.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index f10bd970d50a..7667b12f2ff5 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -423,6 +423,9 @@ alloc_sglist(int nents, int max, int vary)
unsigned i;
unsigned size = max;
+ if (max == 0)
+ return NULL;
+
sg = kmalloc_array(nents, sizeof *sg, GFP_KERNEL);
if (!sg)
return NULL;