diff options
author | Logan Gunthorpe <logang@deltatee.com> | 2019-08-01 01:35:33 +0200 |
---|---|---|
committer | Sagi Grimberg <sagi@grimberg.me> | 2019-08-01 02:57:21 +0200 |
commit | cfc1a1af56200362d1508b82b9a3cc3acb2eae0c (patch) | |
tree | 143bf8acdebccf6d87b8c113fb2ec2d11fce3378 /drivers/nvme/target | |
parent | nvmet-loop: Flush nvme_delete_wq when removing the port (diff) | |
download | linux-cfc1a1af56200362d1508b82b9a3cc3acb2eae0c.tar.xz linux-cfc1a1af56200362d1508b82b9a3cc3acb2eae0c.zip |
nvmet-file: fix nvmet_file_flush() always returning an error
Presently, nvmet_file_flush() always returns a call to
errno_to_nvme_status() but that helper doesn't take into account the
case when errno=0. So nvmet_file_flush() always returns an error code.
All other callers of errno_to_nvme_status() check for success before
calling it.
To fix this, ensure errno_to_nvme_status() returns success if the
errno is zero. This should prevent future mistakes like this from
happening.
Fixes: c6aa3542e010 ("nvmet: add error log support for file backend")
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Diffstat (limited to 'drivers/nvme/target')
-rw-r--r-- | drivers/nvme/target/core.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index b86a23aa9020..3a67e244e568 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c @@ -46,6 +46,9 @@ inline u16 errno_to_nvme_status(struct nvmet_req *req, int errno) u16 status; switch (errno) { + case 0: + status = NVME_SC_SUCCESS; + break; case -ENOSPC: req->error_loc = offsetof(struct nvme_rw_command, length); status = NVME_SC_CAP_EXCEEDED | NVME_SC_DNR; |