Re: [PATCH v2] usb: iowarrior: replace kmalloc with kmalloc_array

From: Oliver Neukum
Date: Mon Aug 27 2018 - 05:21:45 EST


On Do, 2018-08-23 at 12:44 -0500, Gustavo A. R. Silva wrote:
> 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)

I am afraid there is a problem here. The driver currently is a gross
violation of the DMA rules. Unfortunately your patch does not fix that.

That is on anyrhing other than x86 you cannot take the size of a
report,
but you must use the size of a cache line.

Regards
Oliver