From: Chen Zhou <chenzhou10@huawei.com>
To: <davem@davemloft.net>
Cc: <sparclinux@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<chenzhou10@huawei.com>
Subject: [PATCH -next 1/2] sparc: use snprintf() in show_pciobppath_attr() in pci.c
Date: Sat, 9 May 2020 17:18:48 +0800 [thread overview]
Message-ID: <20200509091849.116954-2-chenzhou10@huawei.com> (raw)
In-Reply-To: <20200509091849.116954-1-chenzhou10@huawei.com>
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>
---
arch/sparc/kernel/pci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 5ed43828e078..a41ad562ed4e 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -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);
--
2.20.1
next prev parent reply other threads:[~2020-05-09 9:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-09 9:18 [PATCH -next 0/2] sparc: use snprintf() in show() methods Chen Zhou
2020-05-09 9:18 ` Chen Zhou [this message]
2020-05-09 9:18 ` [PATCH -next 2/2] sparc: use snprintf() in show_pciobppath_attr() in vio.c Chen Zhou
2020-05-09 11:40 ` [PATCH -next 0/2] sparc: use snprintf() in show() methods Joe Perches
2020-05-11 1:24 ` chenzhou
2020-05-11 1:32 ` Joe Perches
2020-05-13 22:36 ` David Miller
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=20200509091849.116954-2-chenzhou10@huawei.com \
--to=chenzhou10@huawei.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=sparclinux@vger.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
all inboxes | Powered by JetHome®