public inbox for linux-edac@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] EDAC/amd64: avoid -Wformat-security warning
@ 2025-12-04 10:02 Arnd Bergmann
  2025-12-04 12:19 ` Zhuo, Qiuxu
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Arnd Bergmann @ 2025-12-04 10:02 UTC (permalink / raw)
  To: Yazen Ghannam, Borislav Petkov, Tony Luck, Avadhut Naik
  Cc: Arnd Bergmann, Ingo Molnar, Qiuxu Zhuo, Thorsten Blum,
	Mario Limonciello, linux-edac, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

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")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/edac/amd64_edac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 2391f3469961..63fca0ee2c23 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -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);
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-12-30 16:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-04 10:02 [PATCH] EDAC/amd64: avoid -Wformat-security warning Arnd Bergmann
2025-12-04 12:19 ` Zhuo, Qiuxu
2025-12-04 15:51 ` Naik, Avadhut
2025-12-04 16:51 ` Yazen Ghannam
2025-12-30 16:37 ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox