Skip to contentSkip to conversation

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

PATCH New Gustavo A. R. Silva 1 participant 1 message Jun 15, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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

---
 drivers/media/test-drivers/vivid/vivid-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/test-drivers/vivid/vivid-core.c +2 -2
index 6c740e3e6999..7abaf858c4a3 100644
@@ -1117,7 +1117,7 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
 	ret = -ENOMEM;
 	/* initialize the test pattern generator */
 	tpg_init(&dev->tpg, 640, 360);
-	if (tpg_alloc(&dev->tpg, MAX_ZOOM * MAX_WIDTH))
+	if (tpg_alloc(&dev->tpg, array_size(MAX_WIDTH, MAX_ZOOM)))
 		goto free_dev;
 	dev->scaled_line = vzalloc(array_size(MAX_WIDTH, MAX_ZOOM));
 	if (!dev->scaled_line)
@@ -1127,7 +1127,7 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
 		goto free_dev;
 
 	/* load the edid */
-	dev->edid = vmalloc(256 * 128);
+	dev->edid = vmalloc(array_size(256, 128));
 	if (!dev->edid)
 		goto free_dev;
 
Signature · 1 line
2.27.0