linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: kernel test robot <lkp@intel.com>,
	Denis Efremov <efremov@linux.com>,
	kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	Nathan Chancellor <natechancellor@gmail.com>,
	Sam Ravnborg <sam@ravnborg.org>,
	Alex Deucher <alexander.deucher@amd.com>,
	Qiujun Huang <hqjagain@gmail.com>, Peter Rosin <peda@axentia.se>,
	dri-devel@lists.freedesktop.org
Subject: Re: [kbuild-all] Re: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings
Date: Tue, 8 Sep 2020 14:08:43 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2009081408160.2478@hadrien> (raw)
In-Reply-To: <3c266a0e-a2b9-ffde-0768-3b4fa89b0bfe@samsung.com>



On Tue, 8 Sep 2020, Bartlomiej Zolnierkiewicz wrote:

>
> Hi,
>
> On 8/10/20 11:21 AM, kernel test robot wrote:
> > From: kernel test robot <lkp@intel.com>
> >
> > drivers/video/fbdev/core/fbcon.c:3509:8-16: WARNING: use scnprintf or sprintf
> > drivers/video/fbdev/core/fbcon.c:3484: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: abfc19ff202d ("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/torvalds/linux.git master
> > head:   fc80c51fd4b23ec007e88d4c688f2cac1b8648e7
> > commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script
> >
> > Please take the patch only if it's a positive warning. Thanks!
> >
> >  fbcon.c |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > --- a/drivers/video/fbdev/core/fbcon.c
> > +++ b/drivers/video/fbdev/core/fbcon.c
> > @@ -3481,7 +3481,7 @@ static ssize_t show_rotate(struct device
> >  	rotate = fbcon_get_rotate(info);
> >  err:
> >  	console_unlock();
> > -	return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
> > +	return scnprintf(buf, PAGE_SIZE, "%d\n", rotate);
>
> buf length is at least PAGE_SIZE and rotate val is an int so
> shouldn't this be converted to use sprintf() instead?

The rule is evolving in this direction.  Thanks for the feedback.

julia

>
> >  }
> >
> >  static ssize_t show_cursor_blink(struct device *device,
> > @@ -3506,7 +3506,7 @@ static ssize_t show_cursor_blink(struct
> >  	blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0;
> >  err:
> >  	console_unlock();
> > -	return snprintf(buf, PAGE_SIZE, "%d\n", blink);
> > +	return scnprintf(buf, PAGE_SIZE, "%d\n", blink);
>
> ditto for blink val
>
> >  }
> >
> >  static ssize_t store_cursor_blink(struct device *device,
> >
>
> Best regards,
> --
> Bartlomiej Zolnierkiewicz
> Samsung R&D Institute Poland
> Samsung Electronics
> _______________________________________________
> kbuild-all mailing list -- kbuild-all@lists.01.org
> To unsubscribe send an email to kbuild-all-leave@lists.01.org
>

      reply	other threads:[~2020-09-08 19:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-10  9:20 drivers/video/fbdev/core/fbcon.c:3509:8-16: WARNING: use scnprintf or sprintf kernel test robot
2020-08-10  9:21 ` [PATCH] coccinelle: api: fix device_attr_show.cocci warnings kernel test robot
2020-09-08 11:37   ` Bartlomiej Zolnierkiewicz
2020-09-08 12:08     ` Julia Lawall [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.22.394.2009081408160.2478@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=alexander.deucher@amd.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=efremov@linux.com \
    --cc=hqjagain@gmail.com \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=natechancellor@gmail.com \
    --cc=peda@axentia.se \
    --cc=sam@ravnborg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).