]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
net: hns3: refine the input parameter 'size' for snprintf()
authorGuojia Liao <liaoguojia@huawei.com>
Tue, 21 Jan 2020 08:42:09 +0000 (16:42 +0800)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 20 Feb 2020 13:58:09 +0000 (07:58 -0600)
BugLink: https://launchpad.net/bugs/1861972
The function snprintf() writes at most size bytes (including the
terminating null byte ('\0') to str. Now, We can guarantee that the
parameter of size is lager than the length of str to be formatting
including its terminating null byte. So it's unnecessary to minus 1
for the input parameter 'size'.

Signed-off-by: Guojia Liao <liaoguojia@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit cdc37385e3abaf2704adf8bb15a2c14f04762d3d)
Signed-off-by: Ike Panhc <ike.pan@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

index 53107b051e9860556abff0a667f06c8b6290ef4c..3685354a8ba246e55efda87901da2cc7409b6826 100644 (file)
@@ -4664,7 +4664,7 @@ static int __init hns3_init_module(void)
        pr_info("%s: %s\n", hns3_driver_name, hns3_copyright);
 
        client.type = HNAE3_CLIENT_KNIC;
-       snprintf(client.name, HNAE3_CLIENT_NAME_LENGTH - 1, "%s",
+       snprintf(client.name, HNAE3_CLIENT_NAME_LENGTH, "%s",
                 hns3_driver_name);
 
        client.ops = &client_ops;