From: Kaushlendra Kumar Date: Tue, 30 Dec 2025 12:45:15 +0000 (+0530) Subject: platform/x86/intel/uncore-freq: Replace sprintf() with scnprintf() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=050a0aab15da9e1d14cd41073046d12d29f443c6;p=thirdparty%2Flinux.git platform/x86/intel/uncore-freq: Replace sprintf() with scnprintf() Replace unbounded sprintf() calls with scnprintf() to prevent potential buffer overflows when formatting device names. While the current format strings cannot overflow the buffer, using scnprintf() follows kernel best practices for string formatting. Signed-off-by: Kaushlendra Kumar Link: https://patch.msgid.link/20251230124516.229125-2-kaushlendra.kumar@intel.com Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen --- diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c index 65897fae17dfb..e9495ac5ecd05 100644 --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c @@ -269,9 +269,10 @@ int uncore_freq_add_entry(struct uncore_data *data, int cpu) goto uncore_unlock; data->instance_id = ret; - sprintf(data->name, "uncore%02d", ret); + scnprintf(data->name, sizeof(data->name), "uncore%02d", ret); } else { - sprintf(data->name, "package_%02d_die_%02d", data->package_id, data->die_id); + scnprintf(data->name, sizeof(data->name), "package_%02d_die_%02d", + data->package_id, data->die_id); } uncore_read(data, &data->initial_min_freq_khz, UNCORE_INDEX_MIN_FREQ);