summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYongqiang Sun <Yongqiang.Sun@amd.com>2026-06-01 22:48:44 +0300
committerAlex Deucher <alexander.deucher@amd.com>2026-06-04 22:27:37 +0300
commit8bfd3aeeb7d4c140434bb9e604fca39ebb3e2937 (patch)
tree81a93f4485d00a1333246b23bc24e68e91038f21
parent342981fff32802a819d6fc7cf3c9fedf9f3d9d60 (diff)
downloadlinux-8bfd3aeeb7d4c140434bb9e604fca39ebb3e2937.tar.xz
drm/amdkfd: fix sysfs topology prop length on buffer truncation
sysfs_show_gen_prop() accumulated snprintf()'s return value into the offset. snprintf() reports bytes that would have been written, not bytes actually written, so a truncated sysfs show could over-report its length. Use sysfs_emit_at(), which returns only the bytes written. Signed-off-by: Yongqiang Sun <Yongqiang.Sun@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_topology.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
index dc1c6bd1252f..00517c3d0e6a 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
@@ -198,8 +198,7 @@ struct kfd_topology_device *kfd_create_topology_device(
#define sysfs_show_gen_prop(buffer, offs, fmt, ...) \
- (offs += snprintf(buffer+offs, PAGE_SIZE-offs, \
- fmt, __VA_ARGS__))
+ (offs += sysfs_emit_at(buffer, offs, fmt, __VA_ARGS__))
#define sysfs_show_32bit_prop(buffer, offs, name, value) \
sysfs_show_gen_prop(buffer, offs, "%s %u\n", name, value)
#define sysfs_show_64bit_prop(buffer, offs, name, value) \