[PATCH 1/3] nvme-core: rework a NQN copying operation
Anthony Wong
anthony.wong at canonical.com
Thu Jan 17 08:31:07 UTC 2019
From: Bart Van Assche <bvanassche at acm.org>
BugLink: https://bugs.launchpad.net/bugs/1811755
Although it is easy to see that the code in nvme_init_subnqn() guarantees that
the subsys->nqn string is '\0'-terminated, apparently Coverity is not smart
enough to see this. Make it easier for Coverity to analyze this code by changing
the strncpy() call into a strlcpy() call. This patch does not change the
behavior of the code but fixes Coveritiy ID 1423720.
Signed-off-by: Bart Van Assche <bvanassche at acm.org>
Reviewed-by: Johannes Thumshirn <jthumshirn at suse.de>
Signed-off-by: Christoph Hellwig <hch at lst.de>
(cherry picked from commit bb2a1d4e804aa41eef0003a192a674f844dbca23)
Signed-off-by: Anthony Wong <anthony.wong at canonical.com>
---
drivers/nvme/host/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 138b2fb..c0d2179 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1943,7 +1943,7 @@ static void nvme_init_subnqn(struct nvme_subsystem *subsys, struct nvme_ctrl *ct
nqnlen = strnlen(id->subnqn, NVMF_NQN_SIZE);
if (nqnlen > 0 && nqnlen < NVMF_NQN_SIZE) {
- strncpy(subsys->subnqn, id->subnqn, NVMF_NQN_SIZE);
+ strlcpy(subsys->subnqn, id->subnqn, NVMF_NQN_SIZE);
return;
}
--
2.7.4
More information about the kernel-team
mailing list