Skip to content

Commit 48925ba

Browse files
Jonathan Velezfloatious
authored andcommitted
ata: libata-transport: replace scnprintf with sysfs_emit for simple attributes
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> Link: https://lore.kernel.org/r/20250709133330.3546-1-jonvelez12345@gmail.com Signed-off-by: Niklas Cassel <cassel@kernel.org>
1 parent c5fccfe commit 48925ba

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/ata/libata-transport.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ show_ata_port_##name(struct device *dev, \
202202
{ \
203203
struct ata_port *ap = transport_class_to_port(dev); \
204204
\
205-
return scnprintf(buf, 20, format_string, cast ap->field); \
205+
return sysfs_emit(buf, format_string, cast ap->field); \
206206
}
207207

208208
#define ata_port_simple_attr(field, name, format_string, type) \
@@ -389,7 +389,7 @@ show_ata_dev_##field(struct device *dev, \
389389
{ \
390390
struct ata_device *ata_dev = transport_class_to_dev(dev); \
391391
\
392-
return scnprintf(buf, 20, format_string, cast ata_dev->field); \
392+
return sysfs_emit(buf, format_string, cast ata_dev->field); \
393393
}
394394

395395
#define ata_dev_simple_attr(field, format_string, type) \

0 commit comments

Comments
 (0)