linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next v2] net: hns3: replace snprintf with scnprintf in hns3_dbg_cmd_read
@ 2020-01-20 12:49 Chen Zhou
  2020-01-21  9:49 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Chen Zhou @ 2020-01-20 12:49 UTC (permalink / raw)
  To: yisen.zhuang, salil.mehta, davem; +Cc: netdev, linux-kernel, chenzhou10

The return value of snprintf may be greater than the size of
HNS3_DBG_READ_LEN, use scnprintf instead in hns3_dbg_cmd_read.

Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
---

changes in v2:
- fix checkpatch style problem.

---
 drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
index 6b328a2..92ee1f5 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
@@ -297,8 +297,8 @@ static ssize_t hns3_dbg_cmd_read(struct file *filp, char __user *buffer,
 	if (!buf)
 		return -ENOMEM;
 
-	len = snprintf(buf, HNS3_DBG_READ_LEN, "%s\n",
-		       "Please echo help to cmd to get help information");
+	len = scnprintf(buf, HNS3_DBG_READ_LEN, "%s\n",
+			"Please echo help to cmd to get help information");
 	uncopy_bytes = copy_to_user(buffer, buf, len);
 
 	kfree(buf);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH -next v2] net: hns3: replace snprintf with scnprintf in hns3_dbg_cmd_read
  2020-01-20 12:49 [PATCH -next v2] net: hns3: replace snprintf with scnprintf in hns3_dbg_cmd_read Chen Zhou
@ 2020-01-21  9:49 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-01-21  9:49 UTC (permalink / raw)
  To: chenzhou10; +Cc: yisen.zhuang, salil.mehta, netdev, linux-kernel

From: Chen Zhou <chenzhou10@huawei.com>
Date: Mon, 20 Jan 2020 20:49:43 +0800

> The return value of snprintf may be greater than the size of
> HNS3_DBG_READ_LEN, use scnprintf instead in hns3_dbg_cmd_read.
> 
> Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
> ---
> 
> changes in v2:
> - fix checkpatch style problem.

Both conversion patches applied, thank you.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-21  9:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-20 12:49 [PATCH -next v2] net: hns3: replace snprintf with scnprintf in hns3_dbg_cmd_read Chen Zhou
2020-01-21  9:49 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).