Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: fbtft: Use devm_kcalloc instead of devm_kzalloc

Replace devm_kzalloc with devm_kcalloc to ensure there are no integer
overflows from the multiplication of a number * sizeof

The following Coccinelle semantic patch was used to make this change:
//<smpl>
@@
expression dev,E1,E2,E3,E4;
@@

- devm_kzalloc(dev,E1*E2*sizeof(E3),E4)
+ devm_kcalloc(dev,E1*E2,sizeof(E3),E4)
//</smpl>

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Amitoj Kaur Chawla and committed by
Greg Kroah-Hartman
0c9ab986 71e03f10

+5 -2
+5 -2
drivers/staging/fbtft/fbtft-core.c
··· 736 736 goto alloc_fail; 737 737 738 738 if (display->gamma_num && display->gamma_len) { 739 - gamma_curves = devm_kzalloc(dev, display->gamma_num * display->gamma_len * sizeof(gamma_curves[0]), 740 - GFP_KERNEL); 739 + gamma_curves = devm_kcalloc(dev, 740 + display->gamma_num * 741 + display->gamma_len, 742 + sizeof(gamma_curves[0]), 743 + GFP_KERNEL); 741 744 if (!gamma_curves) 742 745 goto alloc_fail; 743 746 }