Skip to contentSkip to conversation

imx8mn: buffer overflow in low_drive_gpu_freq()

PATCH In review Heinrich Schuchardt 3 participants 4 messages Apr 17, 2023 – May 2, 2023

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

PATCH 1/1 imx8mn: buffer overflow in low_drive_gpu_freq()

Avoid a buffer overflow if assigned-clock-rates has less than two elements.

Fixes 98bcdf16356c ("imx8mn: Add low drive mode support for DDR4/LPDDR4 EVK")
---
 arch/arm/mach-imx/imx8m/soc.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/mach-imx/imx8m/soc.c +2 -0
index df865e997d..20672ded96 100644
@@ -914,6 +914,8 @@ static int low_drive_gpu_freq(void *blob)
 
 	if (cnt != 7)
 		printf("Warning: %s, assigned-clock-rates count %d\n", nodes_path_8mn[0], cnt);
+	if (cnt < 2)
+		return -1;
 
 	assignedclks[cnt - 1] = 200000000;
 	assignedclks[cnt - 2] = 200000000;
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Heinrich Schuchardt

Avoid a buffer overflow if assigned-clock-rates has less than two elements.

Fixes 98bcdf16356c ("imx8mn: Add low drive mode support for DDR4/LPDDR4 EVK")
Quoted 17 lines
---
  arch/arm/mach-imx/imx8m/soc.c | 2 ++
  1 file changed, 2 insertions(+)
arch/arm/mach-imx/imx8m/soc.c +2 -0
index df865e997d..20672ded96 100644
@@ -914,6 +914,8 @@ static int low_drive_gpu_freq(void *blob)
 
  	if (cnt != 7)
  		printf("Warning: %s, assigned-clock-rates count %d\n", nodes_path_8mn[0], cnt);
+	if (cnt < 2)
+		return -1;
 
  	assignedclks[cnt - 1] = 200000000;
  	assignedclks[cnt - 2] = 200000000;
Reviewed-by on v1 1/1
#2 lore raw
In reply to Heinrich Schuchardt
Quoted 4 lines · Heinrich Schuchardt

Avoid a buffer overflow if assigned-clock-rates has less than two elements.

Fixes 98bcdf16356c ("imx8mn: Add low drive mode support for DDR4/LPDDR4 EVK")
Quoted 17 lines
---
  arch/arm/mach-imx/imx8m/soc.c | 2 ++
  1 file changed, 2 insertions(+)
arch/arm/mach-imx/imx8m/soc.c +2 -0
index df865e997d..20672ded96 100644
@@ -914,6 +914,8 @@ static int low_drive_gpu_freq(void *blob)
 
  	if (cnt != 7)
  		printf("Warning: %s, assigned-clock-rates count %d\n", nodes_path_8mn[0], cnt);
+	if (cnt < 2)
+		return -1;
 
  	assignedclks[cnt - 1] = 200000000;
  	assignedclks[cnt - 2] = 200000000;
#3 lore raw

PATCH 1/1 imx8mn: buffer overflow in low_drive_gpu_freq()

In reply to Heinrich Schuchardt
Quoted 5 lines

Avoid a buffer overflow if assigned-clock-rates has less than two elements.

Fixes 98bcdf16356c ("imx8mn: Add low drive mode support for DDR4/LPDDR4 EVK")

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================