Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0c9ab986 authored by Amitoj Kaur Chawla's avatar Amitoj Kaur Chawla Committed by Greg Kroah-Hartman
Browse files

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: default avatarAmitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 71e03f10
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -736,7 +736,10 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
		goto alloc_fail;

	if (display->gamma_num && display->gamma_len) {
		gamma_curves = devm_kzalloc(dev, display->gamma_num * display->gamma_len * sizeof(gamma_curves[0]),
		gamma_curves = devm_kcalloc(dev,
					    display->gamma_num *
					    display->gamma_len,
					    sizeof(gamma_curves[0]),
					    GFP_KERNEL);
		if (!gamma_curves)
			goto alloc_fail;