snprintf() guarantees NUL-termination within the size limit specified by its second argument. Passing 'sizeof(handle->attr_name) - 1' unnecessarily reduces the usable buffer capacity by one byte, causing sysfs attribute names to be truncated early.
Pass 'sizeof(handle->attr_name)' directly to snprintf() in add_aca_sysfs() to allow full use of the allocated buffer space. Signed-off-by: Sreeraj S Kurup <[email protected]> --- drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c index f22b58c559b6..c2fe98b83eee 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c @@ -682,7 +682,7 @@ static int add_aca_sysfs(struct amdgpu_device *adev, struct aca_handle *handle) { struct device_attribute *aca_attr = &handle->aca_attr; - snprintf(handle->attr_name, sizeof(handle->attr_name) - 1, "aca_%s", handle->name); + snprintf(handle->attr_name, sizeof(handle->attr_name), "aca_%s", handle->name); aca_attr->show = aca_sysfs_read; aca_attr->attr.name = handle->attr_name; aca_attr->attr.mode = S_IRUGO; -- 2.54.0
