From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============1548317837648662479==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings Date: Mon, 14 Dec 2020 23:10:25 +0800 Message-ID: <20201214151025.GA16258@cd96aaed27ba> In-Reply-To: <202012142314.KjiFvIDI-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============1548317837648662479== 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: Bartlomiej Zolnierkiewicz CC: dri-devel(a)lists.freedesktop.org CC: linux-fbdev(a)vger.kernel.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/video/fbdev/core/fbsysfs.c:233:8-16: WARNING: use scnprintf or spri= ntf drivers/video/fbdev/core/fbsysfs.c:421:8-16: WARNING: use scnprintf or spri= ntf drivers/video/fbdev/core/fbsysfs.c:393:8-16: WARNING: use scnprintf or spri= ntf drivers/video/fbdev/core/fbsysfs.c:384:8-16: WARNING: use scnprintf or spri= ntf drivers/video/fbdev/core/fbsysfs.c:260:8-16: WARNING: use scnprintf or spri= ntf drivers/video/fbdev/core/fbsysfs.c:296:8-16: WARNING: use scnprintf or spri= ntf drivers/video/fbdev/core/fbsysfs.c:288:8-16: WARNING: use scnprintf or spri= ntf 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: 2c85ebc57b3e1817b6ce1a6b703928e113a90442 commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add devic= e_attr_show script :::::: branch date: 16 hours ago :::::: commit date: 4 months ago Please take the patch only if it's a positive warning. Thanks! fbsysfs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) --- a/drivers/video/fbdev/core/fbsysfs.c +++ b/drivers/video/fbdev/core/fbsysfs.c @@ -230,7 +230,7 @@ static ssize_t show_bpp(struct device *d char *buf) { struct fb_info *fb_info =3D dev_get_drvdata(device); - return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.bits_per_pixel); + return scnprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.bits_per_pixel); } = static ssize_t store_rotate(struct device *device, @@ -257,7 +257,7 @@ static ssize_t show_rotate(struct device { struct fb_info *fb_info =3D dev_get_drvdata(device); = - return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.rotate); + return scnprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.rotate); } = static ssize_t store_virtual(struct device *device, @@ -285,7 +285,7 @@ static ssize_t show_virtual(struct devic struct device_attribute *attr, char *buf) { struct fb_info *fb_info =3D dev_get_drvdata(device); - return snprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xres_virtual, + return scnprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xres_virtual, fb_info->var.yres_virtual); } = @@ -293,7 +293,7 @@ static ssize_t show_stride(struct device struct device_attribute *attr, char *buf) { struct fb_info *fb_info =3D dev_get_drvdata(device); - return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->fix.line_length); + return scnprintf(buf, PAGE_SIZE, "%d\n", fb_info->fix.line_length); } = static ssize_t store_blank(struct device *device, @@ -381,7 +381,7 @@ static ssize_t show_pan(struct device *d struct device_attribute *attr, char *buf) { struct fb_info *fb_info =3D dev_get_drvdata(device); - return snprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xoffset, + return scnprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xoffset, fb_info->var.yoffset); } = @@ -390,7 +390,7 @@ static ssize_t show_name(struct device * { struct fb_info *fb_info =3D dev_get_drvdata(device); = - return snprintf(buf, PAGE_SIZE, "%s\n", fb_info->fix.id); + return scnprintf(buf, PAGE_SIZE, "%s\n", fb_info->fix.id); } = static ssize_t store_fbstate(struct device *device, @@ -418,7 +418,7 @@ static ssize_t show_fbstate(struct devic struct device_attribute *attr, char *buf) { struct fb_info *fb_info =3D dev_get_drvdata(device); - return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->state); + return scnprintf(buf, PAGE_SIZE, "%d\n", fb_info->state); } = #if IS_ENABLED(CONFIG_FB_BACKLIGHT) --===============1548317837648662479==--