[V3 1/4] nvmet: set right status on error in id-ns handler

Keith Busch kbusch at kernel.org
Tue Jan 12 16:48:01 EST 2021


On Tue, Jan 12, 2021 at 01:14:07PM -0800, Chaitanya Kulkarni wrote:
> @@ -541,7 +543,9 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)
>  		id->nsattr |= (1 << 0);
>  	nvmet_put_namespace(ns);
>  done:
> -	status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id));
> +	if (nvmet_copy_to_sgl(req, 0, id, sizeof(*id)) && !status)
> +		status = NVME_SC_SGL_INVALID_DATA | NVME_SC_DNR;

If the status is already in error, you don't need to copy out the
blank struct, right? Shouldn't this be like:

	if (!status)
		status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id));



More information about the Linux-nvme mailing list