crypto: hisilicon - fix strncpy warning with strscpy
authorZhangfei Gao <zhangfei.gao@linaro.org>
Mon, 15 Jun 2020 03:38:37 +0000 (11:38 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 26 Jun 2020 04:46:42 +0000 (14:46 +1000)
Use strscpy to fix the warning
warning: 'strncpy' specified bound 64 equals destination size

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/hisilicon/qm.c

index 13ccb9e..9762fd1 100644 (file)
@@ -2170,8 +2170,12 @@ static int qm_alloc_uacce(struct hisi_qm *qm)
                .flags = UACCE_DEV_SVA,
                .ops = &uacce_qm_ops,
        };
+       int ret;
 
-       strncpy(interface.name, pdev->driver->name, sizeof(interface.name));
+       ret = strscpy(interface.name, pdev->driver->name,
+                     sizeof(interface.name));
+       if (ret < 0)
+               return -ENAMETOOLONG;
 
        uacce = uacce_alloc(&pdev->dev, &interface);
        if (IS_ERR(uacce))