[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f6107f3e467f1906abdcc33d35f13cf54f7e5a96.1603371258.git.sylphrenadin@gmail.com>
Date: Thu, 22 Oct 2020 19:17:56 +0530
From: Sumera Priyadarsini <sylphrenadin@...il.com>
To: dri-devel@...ts.freedesktop.org
Cc: outreachy-kernel@...glegroups.com, alexander.deucher@....com,
christian.koenig@....com, airlied@...ux.ie, daniel@...ll.ch,
melissa.srw@...il.com, linux-media@...r.kernel.org,
amd-gfx@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: [PATCH 4/5] gpu: drm: amdgpu: Replace snprintf() with sysfs_emit()
Using snprintf() for show() methods holds the risk of buffer overrun
as snprintf() does not know the PAGE_SIZE maximum of the temporary
buffer used to output sysfs content.
Modify amdgpu_psp.c to use sysfs_emit() instead which knows the
size of the temporary buffer.
Issue found with Coccinelle.
Signed-off-by: Sumera Priyadarsini <sylphrenadin@...il.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index d6c38e24f130..4d1d1e1b005d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -2621,7 +2621,7 @@ static ssize_t psp_usbc_pd_fw_sysfs_read(struct device *dev,
return ret;
}
- return snprintf(buf, PAGE_SIZE, "%x\n", fw_ver);
+ return sysfs_emit(buf, PAGE_SIZE, "%x\n", fw_ver);
}
static ssize_t psp_usbc_pd_fw_sysfs_write(struct device *dev,
--
2.25.1
Powered by blists - more mailing lists