Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Wagner <wagi@kernel.org>
To: James Smart <james.smart@broadcom.com>,
	Christoph Hellwig <hch@lst.de>,  Sagi Grimberg <sagi@grimberg.me>,
	Chaitanya Kulkarni <kch@nvidia.com>
Cc: Hannes Reinecke <hare@suse.de>, Keith Busch <kbusch@kernel.org>,
	 linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
	 Daniel Wagner <wagi@kernel.org>
Subject: [PATCH v6 14/14] nvme-fc: do not reference lsrsp after failure
Date: Wed, 07 May 2025 14:23:10 +0200	[thread overview]
Message-ID: <20250507-nvmet-fcloop-v6-14-ca02e16fb018@kernel.org> (raw)
In-Reply-To: <20250507-nvmet-fcloop-v6-0-ca02e16fb018@kernel.org>

The lsrsp object is maintained by the LLDD. The lifetime of the lsrsp
object is implicit. Because there is no explicit cleanup/free call into
the LLDD, it is not safe to assume after xml_rsp_fails, that the lsrsp
is still valid. The LLDD could have freed the object already.

With the recent changes how fcloop tracks the resources, this is the
case. Thus don't access lsrsp after xml_rsp_fails.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
---
 drivers/nvme/host/fc.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 2257c3c96dd2da11097d2d0d4a5bb8ece1bebc6a..fdafa3e9e66fa9b8954209efa14d3b207cb8653c 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -1410,9 +1410,8 @@ nvme_fc_xmt_disconnect_assoc(struct nvme_fc_ctrl *ctrl)
 }
 
 static void
-nvme_fc_xmt_ls_rsp_done(struct nvmefc_ls_rsp *lsrsp)
+nvme_fc_xmt_ls_rsp_free(struct nvmefc_ls_rcv_op *lsop)
 {
-	struct nvmefc_ls_rcv_op *lsop = lsrsp->nvme_fc_private;
 	struct nvme_fc_rport *rport = lsop->rport;
 	struct nvme_fc_lport *lport = rport->lport;
 	unsigned long flags;
@@ -1433,6 +1432,14 @@ nvme_fc_xmt_ls_rsp_done(struct nvmefc_ls_rsp *lsrsp)
 	nvme_fc_rport_put(rport);
 }
 
+static void
+nvme_fc_xmt_ls_rsp_done(struct nvmefc_ls_rsp *lsrsp)
+{
+	struct nvmefc_ls_rcv_op *lsop = lsrsp->nvme_fc_private;
+
+	nvme_fc_xmt_ls_rsp_free(lsop);
+}
+
 static void
 nvme_fc_xmt_ls_rsp(struct nvmefc_ls_rcv_op *lsop)
 {
@@ -1450,7 +1457,7 @@ nvme_fc_xmt_ls_rsp(struct nvmefc_ls_rcv_op *lsop)
 		dev_warn(lport->dev,
 			"LLDD rejected LS RSP xmt: LS %d status %d\n",
 			w0->ls_cmd, ret);
-		nvme_fc_xmt_ls_rsp_done(lsop->lsrsp);
+		nvme_fc_xmt_ls_rsp_free(lsop);
 		return;
 	}
 }

-- 
2.49.0



  parent reply	other threads:[~2025-05-07 12:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-07 12:22 [PATCH v6 00/14] nvmet-fcloop: track resources via reference counting Daniel Wagner
2025-05-07 12:22 ` [PATCH v6 01/14] nvmet-fcloop: track ref counts for nports Daniel Wagner
2025-05-07 13:50   ` Hannes Reinecke
2025-05-08 10:06     ` Daniel Wagner
2025-05-07 12:22 ` [PATCH v6 02/14] nvmet-fcloop: remove nport from list on last user Daniel Wagner
2025-05-07 12:22 ` [PATCH v6 03/14] nvmet-fcloop: refactor fcloop_nport_alloc and track lport Daniel Wagner
2025-05-07 12:23 ` [PATCH v6 04/14] nvmet-fcloop: refactor fcloop_delete_local_port Daniel Wagner
2025-05-07 12:23 ` [PATCH v6 05/14] nvmet-fcloop: update refs on tfcp_req Daniel Wagner
2025-05-07 12:23 ` [PATCH v6 06/14] nvmet-fcloop: add missing fcloop_callback_host_done Daniel Wagner
2025-05-07 13:51   ` Hannes Reinecke
2025-05-07 12:23 ` [PATCH v6 07/14] nvmet-fcloop: access fcpreq only when holding reqlock Daniel Wagner
2025-05-07 13:52   ` Hannes Reinecke
2025-05-07 12:23 ` [PATCH v6 08/14] nvmet-fcloop: prevent double port deletion Daniel Wagner
2025-05-07 13:59   ` Hannes Reinecke
2025-05-07 12:23 ` [PATCH v6 09/14] nvmet-fcloop: allocate/free fcloop_lsreq directly Daniel Wagner
2025-05-07 12:23 ` [PATCH v6 10/14] nvmet-fcloop: don't wait for lport cleanup Daniel Wagner
2025-05-07 13:59   ` Hannes Reinecke
2025-05-07 12:23 ` [PATCH v6 11/14] nvmet-fcloop: drop response if targetport is gone Daniel Wagner
2025-05-07 12:23 ` [PATCH v6 12/14] nvmet-fc: free pending reqs on tgtport unregister Daniel Wagner
2025-05-07 12:23 ` [PATCH v6 13/14] nvmet-fc: take tgtport refs for portentry Daniel Wagner
2025-05-07 12:23 ` Daniel Wagner [this message]
2025-05-07 14:00   ` [PATCH v6 14/14] nvme-fc: do not reference lsrsp after failure Hannes Reinecke
2025-05-12 14:16 ` [PATCH v6 00/14] nvmet-fcloop: track resources via reference counting 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=20250507-nvmet-fcloop-v6-14-ca02e16fb018@kernel.org \
    --to=wagi@kernel.org \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=james.smart@broadcom.com \
    --cc=kbusch@kernel.org \
    --cc=kch@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --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