]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
platform/x86: intel/pmt: Replace sprintf() with sysfs_emit()
authorKaushlendra Kumar <kaushlendra.kumar@intel.com>
Thu, 18 Dec 2025 07:48:33 +0000 (13:18 +0530)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tue, 23 Dec 2025 09:27:56 +0000 (11:27 +0200)
Replace sprintf() calls with sysfs_emit() in guid_show(), size_show(),
and offset_show() sysfs attribute handlers. The sysfs_emit() function
provides automatic buffer bounds checking and is the preferred method
for formatting sysfs output per Documentation/filesystems/sysfs.rst.

This improves safety by preventing potential buffer overflows and aligns
with current kernel coding standards for sysfs attribute implementation.

Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Link: https://patch.msgid.link/20251218074833.2948801-1-kaushlendra.kumar@intel.com
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/pmt/class.c

index 7c3023d5d91dec8f039885531622521ec5041d47..be3c8d9e4fff2ac2fe4ee61e5d7f9423a1e4be9a 100644 (file)
@@ -140,7 +140,7 @@ guid_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct intel_pmt_entry *entry = dev_get_drvdata(dev);
 
-       return sprintf(buf, "0x%x\n", entry->guid);
+       return sysfs_emit(buf, "0x%x\n", entry->guid);
 }
 static DEVICE_ATTR_RO(guid);
 
@@ -149,7 +149,7 @@ static ssize_t size_show(struct device *dev, struct device_attribute *attr,
 {
        struct intel_pmt_entry *entry = dev_get_drvdata(dev);
 
-       return sprintf(buf, "%zu\n", entry->size);
+       return sysfs_emit(buf, "%zu\n", entry->size);
 }
 static DEVICE_ATTR_RO(size);
 
@@ -158,7 +158,7 @@ offset_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct intel_pmt_entry *entry = dev_get_drvdata(dev);
 
-       return sprintf(buf, "%lu\n", offset_in_page(entry->base_addr));
+       return sysfs_emit(buf, "%lu\n", offset_in_page(entry->base_addr));
 }
 static DEVICE_ATTR_RO(offset);