Re: [PATCH V3 08/11] nvmet: use min of device_path and disk len

Christoph Hellwig
2021-02-10T08:13:19Z

> 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.