* [PATCH] coccinelle: api: fix device_attr_show.cocci warnings
2020-07-26 23:39 [jlawall:for-5.9 1/7] drivers/scsi/ufs/ufshcd.c:1749:8-16: WARNING: use scnprintf or sprintf kernel test robot
@ 2020-07-26 23:39 ` kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2020-07-26 23:39 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 2719 bytes --]
CC: kbuild-all(a)lists.01.org
TO: Denis Efremov <efremov@linux.com>
CC: Julia Lawall <Julia.Lawall@lip6.fr>
CC: Alim Akhtar <alim.akhtar@samsung.com>
CC: Avri Altman <avri.altman@wdc.com>
CC: "James E.J. Bottomley" <jejb@linux.ibm.com>
CC: "Martin K. Petersen" <martin.petersen@oracle.com>
CC: Stanley Chu <stanley.chu@mediatek.com>
CC: Can Guo <cang@codeaurora.org>
CC: Bean Huo <beanhuo@micron.com>
CC: Bart Van Assche <bvanassche@acm.org>
From: kernel test robot <lkp@intel.com>
drivers/scsi/ufs/ufshcd.c:1749:8-16: WARNING: use scnprintf or sprintf
drivers/scsi/ufs/ufshcd.c:1772:8-16: WARNING: use scnprintf or sprintf
drivers/scsi/ufs/ufshcd.c:1460:8-16: WARNING: use scnprintf 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: 988676da8375 ("coccinelle: api: add device_attr_show script")
CC: Denis Efremov <efremov@linux.com>
Signed-off-by: kernel test robot <lkp@intel.com>
---
tree: https://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux.git for-5.9
head: 89c775cf9e2b970ac05b0f659597a114da2457de
commit: 988676da837516bbfafda5478472fd4265f0de4e [1/7] coccinelle: api: add device_attr_show script
:::::: branch date: 2 days ago
:::::: commit date: 5 weeks ago
Please take the patch only if it's a positive warning. Thanks!
ufshcd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1457,7 +1457,7 @@ static ssize_t ufshcd_clkscale_enable_sh
{
struct ufs_hba *hba = dev_get_drvdata(dev);
- return snprintf(buf, PAGE_SIZE, "%d\n", hba->clk_scaling.is_allowed);
+ return scnprintf(buf, PAGE_SIZE, "%d\n", hba->clk_scaling.is_allowed);
}
static ssize_t ufshcd_clkscale_enable_store(struct device *dev,
@@ -1746,7 +1746,7 @@ static ssize_t ufshcd_clkgate_delay_show
{
struct ufs_hba *hba = dev_get_drvdata(dev);
- return snprintf(buf, PAGE_SIZE, "%lu\n", hba->clk_gating.delay_ms);
+ return scnprintf(buf, PAGE_SIZE, "%lu\n", hba->clk_gating.delay_ms);
}
static ssize_t ufshcd_clkgate_delay_store(struct device *dev,
@@ -1769,7 +1769,7 @@ static ssize_t ufshcd_clkgate_enable_sho
{
struct ufs_hba *hba = dev_get_drvdata(dev);
- return snprintf(buf, PAGE_SIZE, "%d\n", hba->clk_gating.is_enabled);
+ return scnprintf(buf, PAGE_SIZE, "%d\n", hba->clk_gating.is_enabled);
}
static ssize_t ufshcd_clkgate_enable_store(struct device *dev,
^ permalink raw reply [flat|nested] 2+ messages in thread