diff options
author | Gustavo A. R. Silva <gustavo@embeddedor.com> | 2018-08-23 13:55:27 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-09-10 14:05:28 -0400 |
commit | 23feefda22392d44ee4101dfcf946bc87a6c74b3 (patch) | |
tree | 1c23cf16b2fda498cea4ef422e48d2102c76c960 | |
parent | 87f88dfcde0ecde2a1136b8364099dddb9895b12 (diff) |
usb: iowarrior: replace kmalloc with kmalloc_array
A common flaw in the kernel is integer overflow during memory allocation
size calculations. In an effort to reduce the frequency of these bugs,
kmalloc_array was implemented, which allocates memory for an array,
while at the same time detects integer overflow.
This patch replaces cases of:
kmalloc(a * b, gfp)
with:
kmalloc_array(a, b, gfp)
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/usb/misc/iowarrior.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index c2991b8a65ce..ba05dd80a020 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c | |||
@@ -808,8 +808,8 @@ static int iowarrior_probe(struct usb_interface *interface, | |||
808 | dev->int_in_endpoint->bInterval); | 808 | dev->int_in_endpoint->bInterval); |
809 | /* create an internal buffer for interrupt data from the device */ | 809 | /* create an internal buffer for interrupt data from the device */ |
810 | dev->read_queue = | 810 | dev->read_queue = |
811 | kmalloc(((dev->report_size + 1) * MAX_INTERRUPT_BUFFER), | 811 | kmalloc_array(dev->report_size + 1, MAX_INTERRUPT_BUFFER, |
812 | GFP_KERNEL); | 812 | GFP_KERNEL); |
813 | if (!dev->read_queue) | 813 | if (!dev->read_queue) |
814 | goto error; | 814 | goto error; |
815 | /* Get the serial-number of the chip */ | 815 | /* Get the serial-number of the chip */ |