nvme: fix KASAN warning when parsing host nqn
authorHannes Reinecke <hare@suse.de>
Fri, 25 May 2018 09:04:03 +0000 (11:04 +0200)
committerChristoph Hellwig <hch@lst.de>
Fri, 25 May 2018 14:50:12 +0000 (16:50 +0200)
The host nqn actually is smaller than the space reserved for it,
so we should be using strlcpy to keep KASAN happy.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/fabrics.c

index 8cb3d73e957dbe15333ba42d833e3b292fe24f34..aa318136460ef91f9bfa5c804aa36f53740b35eb 100644 (file)
@@ -57,7 +57,7 @@ static struct nvmf_host *nvmf_host_add(const char *hostnqn)
                goto out_unlock;
 
        kref_init(&host->ref);
-       memcpy(host->nqn, hostnqn, NVMF_NQN_SIZE);
+       strlcpy(host->nqn, hostnqn, NVMF_NQN_SIZE);
 
        list_add_tail(&host->list, &nvmf_hosts);
 out_unlock: