From: Zhangfei Gao Date: Mon, 15 Jun 2020 03:38:37 +0000 (+0800) Subject: crypto: hisilicon - fix strncpy warning with strscpy X-Git-Tag: v5.15~3097^2~137 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6ec5e8b5e7148c3ece1850dffd62a493dbfc2d22;p=platform%2Fkernel%2Flinux-starfive.git crypto: hisilicon - fix strncpy warning with strscpy Use strscpy to fix the warning warning: 'strncpy' specified bound 64 equals destination size Reported-by: kernel test robot Signed-off-by: Zhangfei Gao Signed-off-by: Herbert Xu --- diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 13ccb9e..9762fd1f 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -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))