]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
platform/x86/intel-uncore-freq: avoid non-literal format string
authorArnd Bergmann <arnd@arndb.de>
Tue, 10 Jun 2025 09:34:55 +0000 (11:34 +0200)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 12 Jun 2025 09:28:04 +0000 (12:28 +0300)
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.

Fixes: b98fa870fce2 ("platform/x86/intel-uncore-freq: Add attributes to show agent types")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20250610093459.2646337-1-arnd@kernel.org
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c

index 0f8aea18275b0906f67686c366c8b2711273d29c..65897fae17dfbac81ab9ae9ec7a18365704470ad 100644 (file)
@@ -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, " ");
 
-               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");