]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: fbtft: Use kmalloc_array
authorBhaktipriya Shridhar <bhaktipriya96@gmail.com>
Mon, 22 Feb 2016 17:47:16 +0000 (23:17 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 12 Mar 2016 06:09:09 +0000 (22:09 -0800)
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>
drivers/staging/fbtft/fb_agm1264k-fl.c

index 2a50cf957101116f27a14b76ee1364f030ec1efb..ba9fc444b8481f17ce26fb15e820593165d578b7 100644 (file)
@@ -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;