From: Niklas Cassel <cassel@kernel.org>
To: Jonathan Velez <jonvelez12345@gmail.com>
Cc: dlemoal@kernel.org, linux-kernel@vger.kernel.org,
linux-ide@vger.kernel.org, shuah@kernel.org
Subject: Re: [PATCH] ata: libata-transport: replace scnprintf with sysfs_emit for simple attributes
Date: Wed, 9 Jul 2025 15:47:52 +0200 [thread overview]
Message-ID: <aG5zCBjpOuwFs5mh@ryzen> (raw)
In-Reply-To: <20250709133330.3546-1-jonvelez12345@gmail.com>
Hello Jonathan,
You forgot to use -v 2 to git format-patch (so that v2 is in the subject),
and you forgot to add a changelog (changes since v1) after the '---'.
No need to resend, but until next time.
Thank you for your contribution.
Kind regards,
Niklas
On Wed, Jul 09, 2025 at 01:33:30PM +0000, Jonathan Velez wrote:
> sprintf, snprintf, and scnprintf do not consider the PAGE_SIZE maximum
> of the temporary buffer used for outputting sysfs content and they may
> overrun the PAGE_SIZE buffer length.
>
> To avoid output defects with the ATA transport class simple attributes,
> use sysfs_emit instead of scnprintf().
>
> This aligns with the sysfs guidance provided in
> Documentation/filesystems/sysfs.rst.
>
> Signed-off-by: Jonathan Velez <jonvelez12345@gmail.com>
> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
> ---
> drivers/ata/libata-transport.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c
> index e898be49df6b..62415fe67a11 100644
> --- a/drivers/ata/libata-transport.c
> +++ b/drivers/ata/libata-transport.c
> @@ -202,7 +202,7 @@ show_ata_port_##name(struct device *dev, \
> { \
> struct ata_port *ap = transport_class_to_port(dev); \
> \
> - return scnprintf(buf, 20, format_string, cast ap->field); \
> + return sysfs_emit(buf, format_string, cast ap->field); \
> }
>
> #define ata_port_simple_attr(field, name, format_string, type) \
> @@ -389,7 +389,7 @@ show_ata_dev_##field(struct device *dev, \
> { \
> struct ata_device *ata_dev = transport_class_to_dev(dev); \
> \
> - return scnprintf(buf, 20, format_string, cast ata_dev->field); \
> + return sysfs_emit(buf, format_string, cast ata_dev->field); \
> }
>
> #define ata_dev_simple_attr(field, format_string, type) \
> --
> 2.43.0
>
next prev parent reply other threads:[~2025-07-09 13:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-09 13:33 [PATCH] ata: libata-transport: replace scnprintf with sysfs_emit for simple attributes Jonathan Velez
2025-07-09 13:47 ` Niklas Cassel [this message]
2025-07-09 13:49 ` Niklas Cassel
-- strict thread matches above, loose matches on Subject: below --
2025-07-07 12:20 Jonathan Velez
2025-07-08 1:15 ` Damien Le Moal
2025-07-09 13:16 ` Jonathan Velez
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=aG5zCBjpOuwFs5mh@ryzen \
--to=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=jonvelez12345@gmail.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shuah@kernel.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