mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-01 14:44:12 +00:00
staging: fbtft: Use kmalloc_array
Use kmalloc_array instead of kmalloc for arrays to prevent integer overflows. This was done using Coccinelle: @@ expression e1, e2; constant C; type t; @@ ( - kmalloc( + kmalloc_array( e2 - * + , sizeof(e1), C) | - kmalloc( + kmalloc_array( e1 - * + , sizeof(t), C) | - kmalloc( + kmalloc_array( - sizeof(e1) - * e2 + , + sizeof(e1) , C) | - kmalloc( + kmalloc_array( - sizeof(t) - * e1 + , + sizeof(t) , C) ) Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
0df8f51eed
commit
7ce1b3d3ca
1 changed files with 2 additions and 2 deletions
|
@ -272,8 +272,8 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
|
|||
int ret = 0;
|
||||
|
||||
/* buffer to convert RGB565 -> grayscale16 -> Dithered image 1bpp */
|
||||
signed short *convert_buf = kmalloc(par->info->var.xres *
|
||||
par->info->var.yres * sizeof(signed short), GFP_NOIO);
|
||||
signed short *convert_buf = kmalloc_array(par->info->var.xres *
|
||||
par->info->var.yres, sizeof(signed short), GFP_NOIO);
|
||||
|
||||
if (!convert_buf)
|
||||
return -ENOMEM;
|
||||
|
|
Loading…
Reference in a new issue