Skip to contentSkip to conversation

drm/i915/display: Avoid nonliteral printf format string

PATCH In review Arnd Bergmann 3 participants 3 messages Dec 4, 2025

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

PATCH 1/1 drm/i915/display: Avoid nonliteral printf format string

From: Arnd Bergmann <[email protected]>

pipe_config_mismatch() takes a printf-style format string and arguments, not a constant string, so this trigers -Wformat warnings when they are not disabled:

drivers/gpu/drm/i915/display/intel_display.c: In function 'pipe_config_cx0pll_mismatch':
drivers/gpu/drm/i915/display/intel_display.c:4997:9: error: format not a string literal and no format arguments [-Werror=format-security]

 4997 |         pipe_config_mismatch(p, fastset, crtc, name, chipname);
      |         ^~~~~~~~~~~~~~~~~~~~

drivers/gpu/drm/i915/display/intel_display.c: In function 'pipe_config_lt_phy_pll_mismatch':
drivers/gpu/drm/i915/display/intel_display.c:5027:9: error: format not a string literal and no format arguments [-Werror=format-security]

 5027 |         pipe_config_mismatch(p, fastset, crtc, name, chipname);
      |         ^~~~~~~~~~~~~~~~~~~~

Use either the string literal or the trivial "%s" format so the compiler can prove this to be used correctly.

Fixes 45fe957ae769 ("drm/i915/display: Add compare config for MTL+ platforms")
---
 drivers/gpu/drm/i915/display/intel_display.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_display.c +2 -3
index 7b4fd18c60e2..83025d5a4aa9 100644
@@ -4987,7 +4987,7 @@ pipe_config_cx0pll_mismatch(struct drm_printer *p, bool fastset,
 	struct intel_display *display = to_intel_display(crtc);
 	char *chipname = a->use_c10 ? "C10" : "C20";
 
-	pipe_config_mismatch(p, fastset, crtc, name, chipname);
+	pipe_config_mismatch(p, fastset, crtc, name, "%s", chipname);
 
 	drm_printf(p, "expected:\n");
 	intel_cx0pll_dump_hw_state(display, a);
@@ -5022,9 +5022,8 @@ pipe_config_lt_phy_pll_mismatch(struct drm_printer *p, bool fastset,
 				const struct intel_lt_phy_pll_state *b)
 {
 	struct intel_display *display = to_intel_display(crtc);
-	char *chipname = "LTPHY";
 
-	pipe_config_mismatch(p, fastset, crtc, name, chipname);
+	pipe_config_mismatch(p, fastset, crtc, name, "LTPHY");
 
 	drm_printf(p, "expected:\n");
 	intel_lt_phy_dump_hw_state(display, a);
Signature · 1 line
2.39.5
#1 lore raw

✗ Fi.CI.BUILD: failure for drm/i915/display: Avoid nonliteral printf format string

== Series Details ==

== Series Details ==

Series: drm/i915/display: Avoid nonliteral printf format string
URL : https://patchwork.freedesktop.org/series/158481/
State : failure

== Summary ==

Error: patch https://patchwork.freedesktop.org/api/1.0/series/158481/revisions/1/mbox/ not applied
Applying: drm/i915/display: Avoid nonliteral printf format string
Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/display/intel_display.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/i915/display/intel_display.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/i915/display/intel_display.c
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 drm/i915/display: Avoid nonliteral printf format string
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Build failed, no error log produced

maintainer
#2 lore raw
In reply to Arnd Bergmann
Quoted 13 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

pipe_config_mismatch() takes a printf-style format string and arguments, not a constant string, so this trigers -Wformat warnings when they are not disabled:

drivers/gpu/drm/i915/display/intel_display.c: In function 'pipe_config_cx0pll_mismatch':
drivers/gpu/drm/i915/display/intel_display.c:4997:9: error: format not a string literal and no format arguments [-Werror=format-security]

 4997 |         pipe_config_mismatch(p, fastset, crtc, name, chipname);
      |         ^~~~~~~~~~~~~~~~~~~~

drivers/gpu/drm/i915/display/intel_display.c: In function 'pipe_config_lt_phy_pll_mismatch':
drivers/gpu/drm/i915/display/intel_display.c:5027:9: error: format not a string literal and no format arguments [-Werror=format-security]

Quoted 8 lines
 5027 |         pipe_config_mismatch(p, fastset, crtc, name, chipname);
      |         ^~~~~~~~~~~~~~~~~~~~

Use either the string literal or the trivial "%s" format so the compiler can prove this to be used correctly.

Fixes 45fe957ae769 ("drm/i915/display: Add compare config for MTL+ platforms")

Unfortunately, this no longer applies to
drm-intel-next. pipe_config_cx0pll_mismatch() no longer exists. The 2nd hunk is still valid, though, want to send a rebased version?

BR,
Jani.

Quoted 28 lines
---
 drivers/gpu/drm/i915/display/intel_display.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_display.c +2 -3
index 7b4fd18c60e2..83025d5a4aa9 100644
@@ -4987,7 +4987,7 @@ pipe_config_cx0pll_mismatch(struct drm_printer *p, bool fastset,
 	struct intel_display *display = to_intel_display(crtc);
 	char *chipname = a->use_c10 ? "C10" : "C20";
 
-	pipe_config_mismatch(p, fastset, crtc, name, chipname);
+	pipe_config_mismatch(p, fastset, crtc, name, "%s", chipname);
 
 	drm_printf(p, "expected:\n");
 	intel_cx0pll_dump_hw_state(display, a);
@@ -5022,9 +5022,8 @@ pipe_config_lt_phy_pll_mismatch(struct drm_printer *p, bool fastset,
 				const struct intel_lt_phy_pll_state *b)
 {
 	struct intel_display *display = to_intel_display(crtc);
-	char *chipname = "LTPHY";
 
-	pipe_config_mismatch(p, fastset, crtc, name, chipname);
+	pipe_config_mismatch(p, fastset, crtc, name, "LTPHY");
 
 	drm_printf(p, "expected:\n");
 	intel_lt_phy_dump_hw_state(display, a);
Signature · 1 line
Jani Nikula, Intel