diff mbox series

[1/3] PCI: Replace use of snprintf() with scnprintf() in resource_alignment_show()

Message ID 20200824233918.26306-2-kw@linux.com
State New
Headers show
Series PCI: Replace use of snprintf() with scnprintf() in show() functions | expand

Commit Message

Krzysztof Wilczyński Aug. 24, 2020, 11:39 p.m. UTC
Replace use of snprintf() with scnprintf() in order to adhere to the
rules in Documentation/filesystems/sysfs.txt, as per:

  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().

There is no change to the functionality.

Related:
  https://patchwork.kernel.org/patch/9946759/#20969333
  https://lwn.net/Articles/69419

Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
---
 drivers/pci/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index e39c5499770f..e6c904cbf983 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -6350,7 +6350,7 @@  static ssize_t resource_alignment_show(struct bus_type *bus, char *buf)
 
 	spin_lock(&resource_alignment_lock);
 	if (resource_alignment_param)
-		count = snprintf(buf, PAGE_SIZE, "%s", resource_alignment_param);
+		count = scnprintf(buf, PAGE_SIZE, "%s", resource_alignment_param);
 	spin_unlock(&resource_alignment_lock);
 
 	/*