diff options
| author | Dan Carpenter <dan.carpenter@oracle.com> | 2012-11-17 10:06:11 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-11-21 16:32:26 -0500 |
| commit | 564e69893c63cefe4bcbdeda4f940bf68b6b4491 (patch) | |
| tree | d7563b2a16afe3f6d0afcfd290e6b1c6a3650d05 /drivers/usb/misc | |
| parent | fb4e98ab63433c4d3a1588ea91c73f1cd7ebaa00 (diff) | |
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')
| -rw-r--r-- | drivers/usb/misc/usbtest.c | 3 |
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) | |||
| 423 | unsigned i; | 423 | unsigned i; |
| 424 | unsigned size = max; | 424 | unsigned size = max; |
| 425 | 425 | ||
| 426 | if (max == 0) | ||
| 427 | return NULL; | ||
| 428 | |||
| 426 | sg = kmalloc_array(nents, sizeof *sg, GFP_KERNEL); | 429 | sg = kmalloc_array(nents, sizeof *sg, GFP_KERNEL); |
| 427 | if (!sg) | 430 | if (!sg) |
| 428 | return NULL; | 431 | return NULL; |
