Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Return the result from user admin command IOCTL even in case of failure

We copy the result to user if the command is completed from the
controller even if it completes with failure (non-zero) status.
A return status of < 0 indicates the command was not completed
by the controller. The user application may expect the error code
in the result field in case of failure.

Signed-off-by: Chayan Biswas <Chayan.Biswas@sandisk.com>
Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>

authored by

Chayan Biswas and committed by
Matthew Wilcox
cf90bc48 053ab702

+1 -1
+1 -1
drivers/block/nvme-core.c
··· 1439 1439 nvme_free_iod(dev, iod); 1440 1440 } 1441 1441 1442 - if (!status && copy_to_user(&ucmd->result, &cmd.result, 1442 + if ((status >= 0) && copy_to_user(&ucmd->result, &cmd.result, 1443 1443 sizeof(cmd.result))) 1444 1444 status = -EFAULT; 1445 1445