Skip to contentSkip to conversation

drm/msm/a6xx: fix a potential overflow issue

PATCH In review Zhenzhong Duan 3 participants 4 messages Sep 12, 2020 – Sep 16, 2020

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

PATCH 1/1 drm/msm/a6xx: fix a potential overflow issue

It's allocating an array of a6xx_gpu_state_obj structure rathor than its pointers.

This patch fix it.

---
 drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c +1 -1
index b12f5b4..e9ede19 100644
@@ -875,7 +875,7 @@ static void a6xx_get_indexed_registers(struct msm_gpu *gpu,
 	int i;
 
 	a6xx_state->indexed_regs = state_kcalloc(a6xx_state, count,
-		sizeof(a6xx_state->indexed_regs));
+		sizeof(*a6xx_state->indexed_regs));
 	if (!a6xx_state->indexed_regs)
 		return;
 
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Zhenzhong Duan

It's allocating an array of a6xx_gpu_state_obj structure rathor than its pointers.

This patch fix it.

LGTM but should have a Fixes: tag for the stable trees

Fixes d6852b4b2d01 ("drm/msm/a6xx: Track and manage a6xx state memory")
Quoted 20 lines
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c +1 -1
index b12f5b4..e9ede19 100644
@@ -875,7 +875,7 @@ static void a6xx_get_indexed_registers(struct msm_gpu *gpu,
 	int i;
 
 	a6xx_state->indexed_regs = state_kcalloc(a6xx_state, count,
-		sizeof(a6xx_state->indexed_regs));
+		sizeof(*a6xx_state->indexed_regs));
 	if (!a6xx_state->indexed_regs)
 		return;
 
Signature · 1 line
1.8.3.1
Signature · 6 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
Quoted 5 lines · Jordan Crouse
Quoted 3 lines · Zhenzhong Duan

It's allocating an array of a6xx_gpu_state_obj structure rathor than its pointers.

Quoted 8 lines
Quoted 3 lines

This patch fix it.

LGTM but should have a Fixes: tag for the stable trees

Fixes d6852b4b2d01 ("drm/msm/a6xx: Track and manage a6xx state memory")

I had sent a v2 version with same change as you suggested on Sep 14, could you help review it? Thanks
https://lkml.org/lkml/2020/9/13/311

Reviewed-by on v1 1/1
#3 lore raw
In reply to Zhenzhong Duan
Quoted 5 lines · Zhenzhong Duan

It's allocating an array of a6xx_gpu_state_obj structure rathor than its pointers.

This patch fix it.

Quoted 21 lines
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c +1 -1
index b12f5b4..e9ede19 100644
@@ -875,7 +875,7 @@ static void a6xx_get_indexed_registers(struct msm_gpu *gpu,
 	int i;
 
 	a6xx_state->indexed_regs = state_kcalloc(a6xx_state, count,
-		sizeof(a6xx_state->indexed_regs));
+		sizeof(*a6xx_state->indexed_regs));
 	if (!a6xx_state->indexed_regs)
 		return;
 
Signature · 1 line
1.8.3.1