platform/x86/intel-uncore-freq: avoid non-literal format string
Subsystems (2)
PATCH 1/1 platform/x86/intel-uncore-freq: avoid non-literal format string
From: Arnd Bergmann <[email protected]>
Using a string variable in place of a format string causes a W=1 build warning:
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c:61:40: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
61 | length += sysfs_emit_at(buf, length, agent_name[agent]);
| ^~~~~~~~~~~~~~~~~
Use the safer "%s" format string to print it instead.
--- .../x86/intel/uncore-frequency/uncore-frequency-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c +1 -1
@@ -58,7 +58,7 @@ static ssize_t show_agent_types(struct kobject *kobj, struct kobj_attribute *attif (length) length +=sysfs_emit_at (buf, length," " ); - length +=sysfs_emit_at (buf, length, agent_name[agent]); + length +=sysfs_emit_at (buf, length,"%s" , agent_name[agent]); } length +=sysfs_emit_at (buf, length,"\n" );
Signature · 1 line
2.39.5
Quoted 5 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Using a string variable in place of a format string causes a W=1 build warning:
I am not able to reproduce with W=1 with gcc 15.1.1 20250521 (Red Hat 15.1.1-2).
$touch drivers/platform/x86/intel/uncore-frequency/uncore-frequency- common.c
$ make -j128 W=1 DESCEND objtool CALL scripts/checksyscalls.sh INSTALL libsubcmd_headers .pylintrc: warning: ignored by one of the .gitignore files CC [M] drivers/platform/x86/intel/uncore-frequency/uncore-frequency- common.o LD [M] drivers/platform/x86/intel/uncore-frequency/intel-uncore- frequency-common.o
But verified the change:
Thanks,
Srinivas
Quoted 38 lines
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c:61:40: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security] 61 | length +=sysfs_emit_at(buf, length, agent_name[agent]);
|
^~~~~~~~~~~~~~~~~Use the safer "%s" format string to print it instead.
Fixes b98fa870fce2 ("platform/x86/intel-uncore-freq: Add attributesto show agent types")
Signed-off-by Arnd Bergmann <[email protected]>---
.../x86/intel/uncore-frequency/uncore-frequency-common.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
frequency-common.cb/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
index0f8aea18275b..65897fae17df100644
--- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
+++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.cdrivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c +0
-0@@ -58,7 +58,7 @@ static ssize_t show_agent_types(struct kobject *kobj, struct kobj_attribute *att if (length) length += sysfs_emit_at(buf, length, " ");(quoted diff) +0
-1- length += sysfs_emit_at(buf, length,agent_name[agent]);
(quoted diff) +1
-0+ length += sysfs_emit_at(buf, length, "%s",agent_name[agent]);
}
length +=sysfs_emit_at(buf, length, "\n");
Ilpo Järvinen
maintainerQuoted 9 lines · Arnd Bergmann
Using a string variable in place of a format string causes a W=1 build warning:
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c:61:40: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
61 | length +=sysfs_emit_at(buf, length, agent_name[agent]);
| ^~~~~~~~~~~~~~~~~Use the safer "%s" format string to print it instead.
[...]
Thank you for your contribution, it has been applied to my local review-ilpo-fixes branch. Note it will show up in the public platform-drivers-x86/review-ilpo-fixes branch only once I've pushed my local branch there, which might take a while.
The list of commits applied:
[1/1] platform/x86/intel-uncore-freq: avoid non-literal format string
commit: 0c44b46f51a17baa7ab67de1464427116e9c4eaa
--
i.