Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: hare@suse.de (Hannes Reinecke)
Subject: [PATCH 2/3] nvme: do not access request after calling blk_mq_end_request()
Date: Thu,  7 Jun 2018 10:38:46 +0200	[thread overview]
Message-ID: <20180607083847.51019-3-hare@suse.de> (raw)
In-Reply-To: <20180607083847.51019-1-hare@suse.de>

After calling blk_mq_end_request() the request should be considered
freed, so accessing it afterwards might lead to use-after-free error.

Signed-off-by: Hannes Reinecke <hare at suse.com>
---
 drivers/nvme/host/multipath.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 7f34ae260ca9..87bd60b49bbc 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -51,6 +51,7 @@ void nvme_failover_req(struct request *req)
 	struct nvme_ns *ns = req->q->queuedata;
 	struct device *dev = disk_to_dev(ns->disk);
 	unsigned long flags;
+	unsigned int nvme_status = nvme_req(req)->status & 0x7ff;
 	enum nvme_ana_state ana_state;
 	bool ana_state_changed = false;
 
@@ -64,7 +65,7 @@ void nvme_failover_req(struct request *req)
 	 * caused the error:
 	 */
 	ana_state = READ_ONCE(ns->ctrl->ana_state[ns->anagrpid]);
-	switch (nvme_req(req)->status & 0x7ff) {
+	switch (nvme_status) {
 	case NVME_SC_ANA_TRANSITION:
 		if (ana_state != NVME_ANA_CHANGE) {
 			nvme_update_ana_state(ns, NVME_ANA_CHANGE);
-- 
2.12.3

  parent reply	other threads:[~2018-06-07  8:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-07  8:38 [PATCH 0/3] misc nvme fixes Hannes Reinecke
2018-06-07  8:38 ` [PATCH 1/3] nvme: also check for RESETTING state in nvmf_check_if_ready() Hannes Reinecke
2018-06-07  8:41   ` Sagi Grimberg
2018-06-07 11:26     ` Christoph Hellwig
2018-06-12 21:20       ` James Smart
2018-06-07  8:38 ` Hannes Reinecke [this message]
2018-06-07  8:42   ` [PATCH 2/3] nvme: do not access request after calling blk_mq_end_request() Sagi Grimberg
2018-06-07 11:27   ` Christoph Hellwig
2018-06-07  8:38 ` [PATCH 3/3] nvme: bio remapping tracepoint Hannes Reinecke
2018-06-07  8:41   ` Sagi Grimberg
2018-06-07 11:27   ` Christoph Hellwig
2018-06-07 11:33     ` Hannes Reinecke
2018-06-07 11:42       ` Christoph Hellwig
2018-06-07 16:21         ` Jens Axboe
2018-06-11 14:26           ` Christoph Hellwig

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=20180607083847.51019-3-hare@suse.de \
    --to=hare@suse.de \
    /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