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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
87f88dfcde
commit
23feefda22
@@ -808,8 +808,8 @@ static int iowarrior_probe(struct usb_interface *interface,
|
|||||||
dev->int_in_endpoint->bInterval);
|
dev->int_in_endpoint->bInterval);
|
||||||
/* create an internal buffer for interrupt data from the device */
|
/* create an internal buffer for interrupt data from the device */
|
||||||
dev->read_queue =
|
dev->read_queue =
|
||||||
kmalloc(((dev->report_size + 1) * MAX_INTERRUPT_BUFFER),
|
kmalloc_array(dev->report_size + 1, MAX_INTERRUPT_BUFFER,
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!dev->read_queue)
|
if (!dev->read_queue)
|
||||||
goto error;
|
goto error;
|
||||||
/* Get the serial-number of the chip */
|
/* Get the serial-number of the chip */
|
||||||
|
|||||||
Reference in New Issue
Block a user