From: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
To: srinivas.pandruvada@linux.intel.com, hansg@kernel.org,
ilpo.jarvinen@linux.intel.com
Cc: platform-driver-x86@vger.kernel.org,
Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Subject: [PATCH 1/2] platform/x86/intel/uncore-freq: Replace sprintf() with snprintf()
Date: Tue, 30 Dec 2025 13:35:44 +0530 [thread overview]
Message-ID: <20251230080545.224954-2-kaushlendra.kumar@intel.com> (raw)
In-Reply-To: <20251230080545.224954-1-kaushlendra.kumar@intel.com>
Replace unbounded sprintf() calls with snprintf() to prevent potential
buffer overflows when formatting device names. While the current format
strings cannot overflow the buffer, using snprintf() follows kernel
best practices for string formatting.
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
.../x86/intel/uncore-frequency/uncore-frequency-common.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
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 65897fae17df..c129dd450360 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);
+ snprintf(data->name, sizeof(data->name), "uncore%02d", ret);
} else {
- sprintf(data->name, "package_%02d_die_%02d", data->package_id, data->die_id);
+ snprintf(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);
--
2.34.1
next prev parent reply other threads:[~2025-12-30 8:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-30 8:05 [PATCH 0/2] platform/x86/intel/uncore-freq: String handling improvements Kaushlendra Kumar
2025-12-30 8:05 ` Kaushlendra Kumar [this message]
2025-12-30 10:48 ` [PATCH 1/2] platform/x86/intel/uncore-freq: Replace sprintf() with snprintf() Ilpo Järvinen
2025-12-30 12:45 ` Kumar, Kaushlendra
2025-12-30 8:05 ` [PATCH 2/2] platform/x86/intel/uncore-freq: Replace sprintf() with sysfs_emit() Kaushlendra Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251230080545.224954-2-kaushlendra.kumar@intel.com \
--to=kaushlendra.kumar@intel.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox