Skip to contentSkip to conversation

net: hns3: replace snprintf with scnprintf in hns3_dbg_cmd_read

PATCH Superseded Chen Zhou 2 participants 3 messages Jan 19, 2020 – Jan 20, 2020

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chen Zhou

author
#0 lore raw

PATCH 1/1 net: hns3: replace snprintf with scnprintf in hns3_dbg_cmd_read

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

---
 drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +1 -1
index 6b328a2..8fad699 100644
@@ -297,7 +297,7 @@ 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",
+	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);
 
Signature · 1 line
2.7.4
#1 lore raw
Quoted 13 lines · Chen Zhou

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

---
  drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +0 -0
index 6b328a2..8fad699 100644

drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c static ssize_t hns3_dbg_cmd_read(struct file *filp, char __user *buffer, · line 301

Quoted 6 lines
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +1 -1
@@ -297,7 +297,7 @@ 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",
+	len = scnprintf(buf, HNS3_DBG_READ_LEN, "%s\n",
  		       "Please echo help to cmd to get help information");

not align?

Quoted 3 lines
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +0 -0
  	uncopy_bytes = copy_to_user(buffer, buf, len);
 
author
#2 lore raw
Quoted 11 lines · tanhuazhong
Quoted 8 lines · Chen Zhou

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

---
  drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c static ssize_t hns3_dbg_cmd_read(struct file *filp, char __user *buffer, · line 301

Quoted 10 lines
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +1 -0
index 6b328a2..8fad699 100644
@@ -297,7 +297,7 @@ 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",
+    len = scnprintf(buf, HNS3_DBG_READ_LEN, "%s\n",
                 "Please echo help to cmd to get help information");

not align?

Ok, i will fix in next version.

Thanks,
Chen Zhou

Quoted 7 lines

drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c static ssize_t hns3_dbg_cmd_read(struct file *filp, char __user *buffer, · line 303

Quoted 3 lines
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +0 -0
      uncopy_bytes = copy_to_user(buffer, buf, len);
 

.