From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============4527944550201529084==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings Date: Tue, 29 Dec 2020 15:35:25 +0800 Message-ID: <20201229073525.GA122030@e70346cb6b60> In-Reply-To: <202012291520.hBRWsbXW-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============4527944550201529084== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Denis Efremov CC: Julia Lawall CC: Alex Deucher CC: "Christian K=C3=B6nig" CC: David Airlie CC: Daniel Vetter CC: amd-gfx(a)lists.freedesktop.org CC: dri-devel(a)lists.freedesktop.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c:1950:8-16: WARNING: use scnpri= ntf or sprintf From Documentation/filesystems/sysfs.txt: show() must not use snprintf() when formatting the value to be returned to user space. If you can guarantee that an overflow will never happen you can use sprintf() otherwise you must use scnprintf(). Generated by: scripts/coccinelle/api/device_attr_show.cocci Fixes: abfc19ff202d ("coccinelle: api: add device_attr_show script") CC: Denis Efremov Reported-by: kernel test robot Signed-off-by: kernel test robot --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git = master head: dea8dcf2a9fa8cc540136a6cd885c3beece16ec3 commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add devic= e_attr_show script :::::: branch date: 10 hours ago :::::: commit date: 5 months ago Please take the patch only if it's a positive warning. Thanks! amdgpu_atombios.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c @@ -1947,7 +1947,7 @@ static ssize_t amdgpu_atombios_get_vbios struct amdgpu_device *adev =3D drm_to_adev(ddev); struct atom_context *ctx =3D adev->mode_info.atom_context; = - return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version); + return scnprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version); } = static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version, --===============4527944550201529084==--