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

media: test_drivers: vivid-core: Use array_size() helper

The tpg_alloc() and vmalloc() functions have no 2-factor argument form, so
multiplication factors need to be wrapped in array_size().

This issue was found with the help of Coccinelle and, audited and fixed
manually.

Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

authored by

Gustavo A. R. Silva and committed by
Mauro Carvalho Chehab
a32e8adf 961d3b27

+2 -2
+2 -2
drivers/media/test-drivers/vivid/vivid-core.c
··· 1126 1126 ret = -ENOMEM; 1127 1127 /* initialize the test pattern generator */ 1128 1128 tpg_init(&dev->tpg, 640, 360); 1129 - if (tpg_alloc(&dev->tpg, MAX_ZOOM * MAX_WIDTH)) 1129 + if (tpg_alloc(&dev->tpg, array_size(MAX_WIDTH, MAX_ZOOM))) 1130 1130 goto free_dev; 1131 1131 dev->scaled_line = vzalloc(array_size(MAX_WIDTH, MAX_ZOOM)); 1132 1132 if (!dev->scaled_line) ··· 1136 1136 goto free_dev; 1137 1137 1138 1138 /* load the edid */ 1139 - dev->edid = vmalloc(256 * 128); 1139 + dev->edid = vmalloc(array_size(256, 128)); 1140 1140 if (!dev->edid) 1141 1141 goto free_dev; 1142 1142