Skip to contentSkip to conversation

drm/msm/dpu: Fix uninitialized variable

PATCH Superseded Ethan Carter Edwards 2 participants 3 messages Feb 10, 2025

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/msm/dpu: Fix uninitialized variable

There is a possibility for an uninitialized *ret* variable to be returned in some code paths.

Fix this by initializing *ret* to 0.

Addresses-Coverity-ID: 1642546 ("Uninitialized scalar variable")

Fixes 774bcfb731765d ("drm/msm/dpu: add support for virtual planes")
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +1 -1
index 098abc2c0003cde90ce6219c97ee18fa055a92a5..74edaa9ecee72111b70f32b832486aeebe545a28 100644
@@ -1164,7 +1164,7 @@ int dpu_assign_plane_resources(struct dpu_global_state *global_state,
 			       unsigned int num_planes)
 {
 	unsigned int i;
-	int ret;
+	int ret = 0;
 
 	for (i = 0; i < num_planes; i++) {
 		struct drm_plane_state *plane_state = states[i];

---
base-commit: a64dcfb451e254085a7daee5fe51bf22959d52d3
change-id: 20250209-dpu-c3fac78fc617

Best regards,

Signature · 1 line
Ethan Carter Edwards <[email protected]>
#1 lore raw
Quoted 17 lines · Ethan Carter Edwards

There is a possibility for an uninitialized *ret* variable to be returned in some code paths.

Fix this by initializing *ret* to 0.

Addresses-Coverity-ID: 1642546 ("Uninitialized scalar variable")

Fixes 774bcfb731765d ("drm/msm/dpu: add support for virtual planes")
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +0 -0
index 098abc2c0003cde90ce6219c97ee18fa055a92a5..74edaa9ecee72111b70f32b832486aeebe545a28 100644

drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c int dpu_assign_plane_resources(struct dpu_global_state *global_state, · line 1167

Quoted 5 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +1 -1
@@ -1164,7 +1164,7 @@ int dpu_assign_plane_resources(struct dpu_global_state *global_state,
 			       unsigned int num_planes)
 {
 	unsigned int i;
-	int ret;
+	int ret = 0;

Thanks, but I think it better to make the function return ret from within the loop and return explicit 0 if there was no error.

Quoted 12 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +0 -1
 	for (i = 0; i < num_planes; i++) {
 		struct drm_plane_state *plane_state = states[i];
 
---

base-commit: a64dcfb451e254085a7daee5fe51bf22959d52d3
change-id: 20250209-dpu-c3fac78fc617

Best regards,

Signature · 1 line
Ethan Carter Edwards <[email protected]>
Signature · 2 lines
With best wishes
Dmitry
#2 lore raw
Quoted 13 lines · Dmitry Baryshkov
Quoted 12 lines · Ethan Carter Edwards

There is a possibility for an uninitialized *ret* variable to be returned in some code paths.

Fix this by initializing *ret* to 0.

Addresses-Coverity-ID: 1642546 ("Uninitialized scalar variable")

Fixes 774bcfb731765d ("drm/msm/dpu: add support for virtual planes")
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c int dpu_assign_plane_resources(struct dpu_global_state *global_state, · line 1167

Quoted 10 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +1 -1
index 098abc2c0003cde90ce6219c97ee18fa055a92a5..74edaa9ecee72111b70f32b832486aeebe545a28 100644
@@ -1164,7 +1164,7 @@ int dpu_assign_plane_resources(struct dpu_global_state *global_state,
 			       unsigned int num_planes)
 {
 	unsigned int i;
-	int ret;
+	int ret = 0;

Thanks, but I think it better to make the function return ret from within the loop and return explicit 0 if there was no error.

Will do, v2 incoming...

Quoted 17 lines
Quoted 13 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +0 -1
 	for (i = 0; i < num_planes; i++) {
 		struct drm_plane_state *plane_state = states[i];
 
---

base-commit: a64dcfb451e254085a7daee5fe51bf22959d52d3
change-id: 20250209-dpu-c3fac78fc617

Best regards,

Signature · 1 line
Ethan Carter Edwards <[email protected]>
Signature · 2 lines
With best wishes
Dmitry