OSDN Git Service

net: hns3: replace snprintf with scnprintf in hns3_dbg_cmd_read
authorChen Zhou <chenzhou10@huawei.com>
Mon, 20 Jan 2020 12:49:43 +0000 (20:49 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 21 Jan 2020 09:48:17 +0000 (10:48 +0100)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c

index 6b328a2..92ee1f5 100644 (file)
@@ -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);