From 6ec5e8b5e7148c3ece1850dffd62a493dbfc2d22 Mon Sep 17 00:00:00 2001 From: Zhangfei Gao Date: Mon, 15 Jun 2020 11:38:37 +0800 Subject: 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 --- drivers/crypto/hisilicon/qm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 13ccb9e29a2e..9762fd1f299d 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)) -- cgit v1.2.3