Skip to contentSkip to conversation

drm/edid: Fix uninitialized variable in drm_cvt_modes()

PATCH In review Lyude Paul 2 participants 2 messages Nov 5, 2020 – Nov 6, 2020

Subsystems (3)
lore
Share & tools
lore

Lyude Paul

author
#0 lore raw

PATCH v3 1/1 drm/edid: Fix uninitialized variable in drm_cvt_modes()

Noticed this when trying to compile with -Wall on a kernel fork. We potentially don't set width here, which causes the compiler to complain about width potentially being uninitialized in drm_cvt_modes(). So, let's fix that.

Changes since v1:
* Don't emit an error as this code isn't reachable, just mark it as such Changes since v2:
* Remove now unused variable

Cc <[email protected]> # v5.9+
Fixes 3f649ab728cd ("treewide: Remove uninitialized_var() usage")
---
 drivers/gpu/drm/drm_edid.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_edid.c +2 -0
index 631125b46e04..b84efd538a70 100644
@@ -3114,6 +3114,8 @@ static int drm_cvt_modes(struct drm_connector *connector,
 		case 0x0c:
 			width = height * 15 / 9;
 			break;
+		default:
+			unreachable();
 		}
 
 		for (j = 1; j < 5; j++) {
Signature · 1 line
2.28.0
Reviewed-by on v3 1/1
#1 lore raw
Quoted 10 lines · Lyude Paul

Noticed this when trying to compile with -Wall on a kernel fork. We potentially don't set width here, which causes the compiler to complain about width potentially being uninitialized in drm_cvt_modes(). So, let's fix that.

Changes since v1:
* Don't emit an error as this code isn't reachable, just mark it as such Changes since v2:
* Remove now unused variable

Quoted 5 lines
Cc <[email protected]> # v5.9+
Fixes 3f649ab728cd ("treewide: Remove uninitialized_var() usage")

For the very little it's worth,

Quoted 18 lines
---
 drivers/gpu/drm/drm_edid.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_edid.c +2 -1
index 631125b46e04..b84efd538a70 100644
@@ -3114,6 +3114,8 @@ static int drm_cvt_modes(struct drm_connector *connector,
                case 0x0c:
                        width = height * 15 / 9;
                        break;
+               default:
+                       unreachable();
                }
 
                for (j = 1; j < 5; j++) {
--
Quoted 2 lines

2.28.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel