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

Christoph Hellwig hch at lst.de
Wed Jan 13 13:34:25 EST 2021


On Tue, Jan 12, 2021 at 01:48:01PM -0800, Keith Busch wrote:
> 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));

Yes.



More information about the Linux-nvme mailing list