[PATCH V3 08/11] nvmet: use min of device_path and disk len
Christoph Hellwig
hch at lst.de
Wed Feb 10 03:13:06 EST 2021
> static inline void __assign_req_name(char *name, struct nvmet_req *req)
> {
> + size_t len = min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path));
> +
> if (req->ns)
> - strncpy(name, req->ns->device_path, DISK_NAME_LEN);
> + strncpy(name, req->ns->device_path, len);
> else
> memset(name, 0, DISK_NAME_LEN);
This could dereference a NULL req->ns. I've changed the patch
to eliminate the local variable and to return early for the NULL
req->ns case.
More information about the Linux-nvme
mailing list