From: Dan Carpenter Date: Sat, 17 Nov 2012 15:06:11 +0000 (+0300) Subject: USB: usbtest: prevent a divide by zero bug X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=564e69893c63cefe4bcbdeda4f940bf68b6b4491;p=deliverable%2Flinux.git 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 Signed-off-by: Greg Kroah-Hartman --- 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;