From: Logan Gunthorpe <logang@deltatee.com>
To: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org
Cc: Christoph Hellwig <hch@lst.de>, Keith Busch <kbusch@kernel.org>,
Jens Axboe <axboe@fb.com>, Sagi Grimberg <sagi@grimberg.me>,
Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>,
Max Gurtovoy <maxg@mellanox.com>,
Logan Gunthorpe <logang@deltatee.com>
Subject: [PATCH v3 3/4] nvmet-file: fix nvmet_file_flush() always returning an error
Date: Wed, 31 Jul 2019 17:35:33 -0600 [thread overview]
Message-ID: <20190731233534.4841-4-logang@deltatee.com> (raw)
In-Reply-To: <20190731233534.4841-1-logang@deltatee.com>
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>
---
drivers/nvme/target/core.c | 3 +++
1 file changed, 3 insertions(+)
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;
--
2.20.1
next prev parent reply other threads:[~2019-07-31 23:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-31 23:35 [PATCH v3 0/4] Varios NVMe Fixes Logan Gunthorpe
2019-07-31 23:35 ` [PATCH v3 1/4] nvmet: Fix use-after-free bug when a port is removed Logan Gunthorpe
2019-07-31 23:52 ` Chaitanya Kulkarni
2019-07-31 23:35 ` [PATCH v3 2/4] nvmet-loop: Flush nvme_delete_wq when removing the port Logan Gunthorpe
2019-07-31 23:53 ` Chaitanya Kulkarni
2019-07-31 23:35 ` Logan Gunthorpe [this message]
2019-07-31 23:35 ` [PATCH v3 4/4] nvme-core: Fix extra device_put() call on error path Logan Gunthorpe
2019-07-31 23:55 ` Chaitanya Kulkarni
2019-08-01 1:02 ` [PATCH v3 0/4] Varios NVMe Fixes Sagi Grimberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190731233534.4841-4-logang@deltatee.com \
--to=logang@deltatee.com \
--cc=axboe@fb.com \
--cc=chaitanya.kulkarni@wdc.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=maxg@mellanox.com \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox