[PATCH] nvme: fix KASAN warning when parsing host nqn
Christoph Hellwig
hch at lst.de
Mon May 14 05:44:14 PDT 2018
On Mon, May 14, 2018 at 02:23:12PM +0200, Hannes Reinecke wrote:
> - host = kmalloc(sizeof(*host), GFP_KERNEL);
> + host = kzalloc(sizeof(*host), GFP_KERNEL);
> if (!host)
> goto out_unlock;
>
> kref_init(&host->ref);
> - memcpy(host->nqn, hostnqn, NVMF_NQN_SIZE);
> + memcpy(host->nqn, hostnqn, strlen(hostnqn));
That pattern is called strcpy :) And we better use strlcpy here,
just in case.
More information about the Linux-nvme
mailing list