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

Commit 639e0d05 authored by Sunil Khatri's avatar Sunil Khatri
Browse files

msm: kgsl: Make sure gpu-speed-bin-vectors has the correct size



Total number of elements in the gpu-speed-bin-vectors array
should be multiple of number of elements in a speed bin vector.

If number of elements is not a multiple of vector size then
there is a possibilty of out of bound access in the speed-bin
vector array. Also rectify the memory allocated for it.

Change-Id: I9158e4f883eca400a46663b07326fb6f6020155c
Signed-off-by: default avatarSunil Khatri <sunilkh@codeaurora.org>
parent 378dc16e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -294,11 +294,11 @@ void adreno_efuse_speed_bin_array(struct adreno_device *adreno_dev)
	 */
	count = of_property_count_u32_elems(device->pdev->dev.of_node,
				"qcom,gpu-speed-bin-vectors");
	if (count <= 0)

	if ((count <= 0) || (count % vector_size))
		return;

	bin_vector = kmalloc(sizeof(count * sizeof(unsigned int)),
			GFP_KERNEL);
	bin_vector = kmalloc_array(count, sizeof(unsigned int), GFP_KERNEL);
	if (bin_vector == NULL) {
		KGSL_DRV_ERR(device,
				"Unable to allocate memory for speed-bin vector\n");