Skip to contentSkip to conversation

EDAC/amd64: avoid -Wformat-security warning

PATCH Applied Arnd Bergmann 5 participants 5 messages Dec 4, 2025 – Dec 30, 2025

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

PATCH 1/1 EDAC/amd64: avoid -Wformat-security warning

From: Arnd Bergmann <[email protected]>

Using a variable as a format string causes a (default-disabled) warning:

drivers/edac/amd64_edac.c: In function 'per_family_init':
drivers/edac/amd64_edac.c:3914:17: error: format not a string literal and no format arguments [-Werror=format-security]

 3914 |                 scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), tmp_name);
      |                 ^~~~~~~~~

The code here is safe, but in order to enable the warning by default in the future, change this instance to pass the name indirectly.

Fixes e9abd990aefd ("EDAC/amd64: Generate ctl_name string at runtime")
---
 drivers/edac/amd64_edac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/edac/amd64_edac.c +1 -1
index 2391f3469961..63fca0ee2c23 100644
@@ -3911,7 +3911,7 @@ static int per_family_init(struct amd64_pvt *pvt)
 	}
 
 	if (tmp_name)
-		scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), tmp_name);
+		scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), "%s", tmp_name);
 	else
 		scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), "F%02Xh_M%02Xh",
 			  pvt->fam, pvt->model);
Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 22 lines

From: Arnd Bergmann <[email protected]>
Sent: Thursday, December 4, 2025 6:02 PM
To: Yazen Ghannam <[email protected]>; Borislav Petkov <[email protected]>; Luck, Tony <[email protected]>; Avadhut Naik <[email protected]>
Cc: Arnd Bergmann <[email protected]>; Ingo Molnar <[email protected]>; Zhuo, Qiuxu <[email protected]>; Thorsten Blum <[email protected]>; Mario Limonciello <[email protected]>; [email protected]; linux- [email protected]
Subject: [PATCH] EDAC/amd64: avoid -Wformat-security warning

From: Arnd Bergmann <[email protected]>

Using a variable as a format string causes a (default-disabled) warning:

drivers/edac/amd64_edac.c: In function 'per_family_init':
drivers/edac/amd64_edac.c:3914:17: error: format not a string literal and no format arguments [-Werror=format-security]

 3914 |                 scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), tmp_name);
      |                 ^~~~~~~~~
Quoted 6 lines

The code here is safe, but in order to enable the warning by default in the future, change this instance to pass the name indirectly.

Fixes e9abd990aefd ("EDAC/amd64: Generate ctl_name string at runtime")

---

LGTM. Thanks!

[...]

Reviewed-by Avadhut Naik on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 23 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Using a variable as a format string causes a (default-disabled) warning:

drivers/edac/amd64_edac.c: In function 'per_family_init':
drivers/edac/amd64_edac.c:3914:17: error: format not a string literal and no format arguments [-Werror=format-security]

 3914 |                 scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), tmp_name);
      |                 ^~~~~~~~~

The code here is safe, but in order to enable the warning by default in the future, change this instance to pass the name indirectly.

Fixes e9abd990aefd ("EDAC/amd64: Generate ctl_name string at runtime")
---
 drivers/edac/amd64_edac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/edac/amd64_edac.c +0 -0
index 2391f3469961..63fca0ee2c23 100644

drivers/edac/amd64_edac.c static int per_family_init(struct amd64_pvt *pvt) · line 3917

Quoted 8 lines
drivers/edac/amd64_edac.c +1 -1
@@ -3911,7 +3911,7 @@ static int per_family_init(struct amd64_pvt *pvt)
 	}
 
 	if (tmp_name)
-		scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), tmp_name);
+		scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), "%s", tmp_name);
 	else
 		scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), "F%02Xh_M%02Xh",
 			  pvt->fam, pvt->model);

Thanks for fixing this!

Signature · 2 lines
Thanks,
Avadhut Naik
maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Arnd Bergmann
Quoted 9 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Using a variable as a format string causes a (default-disabled) warning:

drivers/edac/amd64_edac.c: In function 'per_family_init':
drivers/edac/amd64_edac.c:3914:17: error: format not a string literal and no format arguments [-Werror=format-security]

 3914 |                 scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), tmp_name);
      |                 ^~~~~~~~~
Quoted 6 lines

The code here is safe, but in order to enable the warning by default in the future, change this instance to pass the name indirectly.

Fixes e9abd990aefd ("EDAC/amd64: Generate ctl_name string at runtime")

---

Thanks,
Yazen

maintainer Applied
#4 lore raw
In reply to Arnd Bergmann
Quoted 24 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Using a variable as a format string causes a (default-disabled) warning:

drivers/edac/amd64_edac.c: In function 'per_family_init':
drivers/edac/amd64_edac.c:3914:17: error: format not a string literal and no format arguments [-Werror=format-security]

 3914 |                 scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), tmp_name);
      |                 ^~~~~~~~~

The code here is safe, but in order to enable the warning by default in the future, change this instance to pass the name indirectly.

Fixes e9abd990aefd ("EDAC/amd64: Generate ctl_name string at runtime")
---
 drivers/edac/amd64_edac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/edac/amd64_edac.c +0 -0
index 2391f3469961..63fca0ee2c23 100644

drivers/edac/amd64_edac.c static int per_family_init(struct amd64_pvt *pvt) · line 3917

Quoted 8 lines
drivers/edac/amd64_edac.c +1 -1
@@ -3911,7 +3911,7 @@ static int per_family_init(struct amd64_pvt *pvt)
 	}
 
 	if (tmp_name)
-		scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), tmp_name);
+		scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), "%s", tmp_name);
 	else
 		scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), "F%02Xh_M%02Xh",
 			  pvt->fam, pvt->model);

Applied, thanks.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette