linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhangfei Gao <zhangfei.gao@linaro.org>
To: "Herbert Xu " <herbert@gondor.apana.org.au>,
	" Greg Kroah-Hartman " <gregkh@linuxfoundation.org>,
	" Eric Biggers" <ebiggers@kernel.org>,
	"Jonathan Cameron " <Jonathan.Cameron@huawei.com>,
	 wangzhou1  <wangzhou1@hisilicon.com>
Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
	kbuild-all@lists.01.org, Zhangfei Gao <zhangfei.gao@linaro.org>
Subject: [PATCH v2] crypto: hisilicon - fix strncpy warning with strscpy
Date: Mon, 15 Jun 2020 11:38:37 +0800	[thread overview]
Message-ID: <1592192317-10566-1-git-send-email-zhangfei.gao@linaro.org> (raw)
In-Reply-To: <1591241524-6452-1-git-send-email-zhangfei.gao@linaro.org>

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>
---
v2: Use strscpy instead of strlcpy since better truncation handling
    suggested by Herbert
    Rebase to 5.8-rc1

 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 9bb263cec6c3..8ac293afa8ab 100644
--- a/drivers/crypto/hisilicon/qm.c
+++ b/drivers/crypto/hisilicon/qm.c
@@ -2179,8 +2179,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))
-- 
2.23.0


  parent reply	other threads:[~2020-06-15  3:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <202006032110.BEbKqovX%lkp@intel.com>
2020-06-04  3:32 ` [PATCH] crypto: hisilicon - fix strncpy warning with strlcpy Zhangfei Gao
2020-06-04  3:39   ` Herbert Xu
2020-06-04  6:10     ` Zhangfei Gao
2020-06-04  6:18       ` Herbert Xu
2020-06-04  6:44         ` Zhangfei Gao
2020-06-04  6:50           ` Herbert Xu
2020-06-04 13:52             ` Zhou Wang
2020-06-05  9:34             ` Zhangfei Gao
2020-06-05 12:17               ` Herbert Xu
2020-06-05 15:26                 ` Zhangfei Gao
2020-06-05 15:49                   ` Eric Biggers
2020-06-06  1:42                     ` Zhangfei Gao
2020-06-07 13:03                 ` David Laight
2020-06-10  6:56                   ` Eric Biggers
2020-06-15  3:38   ` Zhangfei Gao [this message]
2020-06-26  6:06     ` [PATCH v2] crypto: hisilicon - fix strncpy warning with strscpy Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1592192317-10566-1-git-send-email-zhangfei.gao@linaro.org \
    --to=zhangfei.gao@linaro.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=ebiggers@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wangzhou1@hisilicon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).