sparc: use scnprintf() in show_pciobppath_attr() in pci.c
authorChen Zhou <chenzhou10@huawei.com>
Sat, 9 May 2020 09:18:48 +0000 (17:18 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 13 May 2020 22:35:58 +0000 (15:35 -0700)
snprintf() returns the number of bytes that would be written,
which may be greater than the the actual length to be written.

show_pciobppath_attr() should return the number of bytes printed
into the buffer. This is the return value of scnprintf().

Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc/kernel/pci.c

index 5ed43828e0787c6b5f00fddfc7b56e56ff25f0e5..a41ad562ed4ea6b7264f99ca3bd30f3c7668070c 100644 (file)
@@ -593,7 +593,7 @@ show_pciobppath_attr(struct device * dev, struct device_attribute * attr, char *
        pdev = to_pci_dev(dev);
        dp = pdev->dev.of_node;
 
-       return snprintf (buf, PAGE_SIZE, "%pOF\n", dp);
+       return scnprintf(buf, PAGE_SIZE, "%pOF\n", dp);
 }
 
 static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH, show_pciobppath_attr, NULL);