public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Ruslan Valiyev <linuxoid@gmail.com>
Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>,
	Johan Hovold <johan@kernel.org>, Alex Elder <elder@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: greybus: arche: use sysfs_emit() instead of sprintf()
Date: Thu, 26 Feb 2026 10:18:22 +0300	[thread overview]
Message-ID: <aZ_zvtpatfhcCd0i@stanley.mountain> (raw)
In-Reply-To: <20260225212955.57102-1-linuxoid@gmail.com>

On Wed, Feb 25, 2026 at 09:29:55PM +0000, Ruslan Valiyev wrote:
> Replace sprintf() with sysfs_emit() in state_show() sysfs attribute
> callbacks in arche-platform.c and arche-apb-ctrl.c.
> 
> sysfs_emit() is preferred over sprintf() in sysfs show functions
> because it is aware of the PAGE_SIZE buffer limit, preventing
> potential buffer overflows. This addresses checkpatch warnings
> about the use of sprintf() in sysfs show callbacks.
> 
> Signed-off-by: Ruslan Valiyev <linuxoid@gmail.com>
> ---

I really want these sorts of patches to have some kind of analysis
whether the "potential buffer overflows" are actual buffer overflows or
not.  In this case, it's really easy to see that there are no buffer
overflows so it feels petty for something I can see just by glancing
at the patch...  I just got finished asking for the same thing from
someone else, but in that case I had to look up the buffer size.

Anyway, just add a sentence at the start which says that "This code is
obviously safe".  And remove the bits which mention "potential buffer
overflows".

    Checkpatch complains about code using sprintf().  This code here is
    obviously safe as-is, but it would be more appropriate to use
    sysfs_emit().

regards,
dan carpenter

  reply	other threads:[~2026-02-26  7:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 21:29 [PATCH] staging: greybus: arche: use sysfs_emit() instead of sprintf() Ruslan Valiyev
2026-02-26  7:18 ` Dan Carpenter [this message]
2026-02-26  7:48 ` [PATCH v2] " Ruslan Valiyev
2026-02-26  8:00   ` Dan Carpenter

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=aZ_zvtpatfhcCd0i@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=elder@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=greybus-dev@lists.linaro.org \
    --cc=hvaibhav.linux@gmail.com \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=linuxoid@gmail.com \
    /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