From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============3406233455000349554==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings Date: Fri, 03 Jul 2020 19:35:52 +0800 Message-ID: <20200703113552.GA18596@bf425ecdd42c> In-Reply-To: <202007031941.um9p1FRJ%lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============3406233455000349554== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: kbuild-all(a)lists.01.org TO: Denis Efremov CC: Julia Lawall CC: Alex Deucher CC: "Christian K=C3=B6nig" CC: David Airlie CC: Daniel Vetter CC: Hawking Zhang CC: John Clements CC: Xiaojie Yuan CC: Evan Quan From: kernel test robot drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c:2154:8-16: WARNING: use scnprintf o= r 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: 988676da8375 ("coccinelle: api: add device_attr_show script") CC: Denis Efremov Signed-off-by: kernel test robot --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux.git f= or-5.9 head: 5502a4eb3af819792a6c43b418c401f613a39d02 commit: 988676da837516bbfafda5478472fd4265f0de4e [1/3] coccinelle: api: add= device_attr_show script :::::: branch date: 8 days ago :::::: commit date: 9 days ago Please take the patch only if it's a positive warning. Thanks! amdgpu_psp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c @@ -2151,7 +2151,7 @@ static ssize_t psp_usbc_pd_fw_sysfs_read return ret; } = - return snprintf(buf, PAGE_SIZE, "%x\n", fw_ver); + return scnprintf(buf, PAGE_SIZE, "%x\n", fw_ver); } = static ssize_t psp_usbc_pd_fw_sysfs_write(struct device *dev, --===============3406233455000349554==--