projects/linux·commit c816ba1d

EDAC/amd64: Avoid a -Wformat-security warning

c816ba1d · Arnd Bergmann <[email protected]> · 2025-12-04 11:02:25 +01:00

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 <[email protected]>
Signed-off-by: Borislav Petkov (AMD) <[email protected]>
Reviewed-by: Avadhut Naik <[email protected]>
Reviewed-by: Qiuxu Zhuo <[email protected]>
Reviewed-by: Yazen Ghannam <[email protected]>
Link: https://patch.msgid.link/[email protected]
Commit
c816ba1dcd931b9db8d66c71e1ae34ddcdbf968f
Parents
8f0b4cce

Changes

1 files changed · +1 −1

FileStatusAddDelContent
drivers/edac/amd64_edac.cmodified+1−1View file

drivers/edac/amd64_edac.c

View file
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 2391f34..63fca0e 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);