Skip to content

Commit 7e67a0a

Browse files
committed
ACPI: TAD: Replace sprintf() with sysfs_emit()
JIRA: https://issues.redhat.com/browse/RHEL-114091 commit cf115eb Author: Sukrut Heroorkar <hsukrut3@gmail.com> Date: Wed, 16 Jul 2025 21:14:00 +0000 Replace sprintf() in *_show() callbacks of sysfs attributes with sysfs_emit(). While the current implementation works, sysfs_emit() helps to prevent potential buffer overflows and aligns with kernel documentation Documentation/filesystems/sysfs.rst. Tested on an x86_64 system with acpi_tad built as a module: - Inserted patched acpi_tad.ko successfully - Verified /sys/devices/platform/ACPI000E:00/time and /caps are accessible - Confirmed correct output from 'cat' with no dmesg errors Signed-off-by: Sukrut Heroorkar <hsukrut3@gmail.com> Link: https://patch.msgid.link/20250716123543.495628-1-hsukrut3@gmail.com [ rjw: Changelog edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
1 parent 65f30e2 commit 7e67a0a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/acpi/acpi_tad.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ static ssize_t time_show(struct device *dev, struct device_attribute *attr,
233233
if (ret)
234234
return ret;
235235

236-
return sprintf(buf, "%u:%u:%u:%u:%u:%u:%d:%u\n",
236+
return sysfs_emit(buf, "%u:%u:%u:%u:%u:%u:%d:%u\n",
237237
rt.year, rt.month, rt.day, rt.hour, rt.minute, rt.second,
238238
rt.tz, rt.daylight);
239239
}
@@ -428,7 +428,7 @@ static ssize_t caps_show(struct device *dev, struct device_attribute *attr,
428428
{
429429
struct acpi_tad_driver_data *dd = dev_get_drvdata(dev);
430430

431-
return sprintf(buf, "0x%02X\n", dd->capabilities);
431+
return sysfs_emit(buf, "0x%02X\n", dd->capabilities);
432432
}
433433

434434
static DEVICE_ATTR_RO(caps);

0 commit comments

Comments
 (0)