]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nvmet-fcloop: update refs on tfcp_req
authorDaniel Wagner <wagi@kernel.org>
Wed, 7 May 2025 12:23:01 +0000 (14:23 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 20 May 2025 03:34:26 +0000 (05:34 +0200)
Track the lifetime of the in-flight tfcp_req to ensure
the object is not freed too early.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/target/fcloop.c

index a1ceeca264beebe678876dc627bd54a5554a8d31..8af809ce963ad6ea8b042e6e24d45e74f57b1d4d 100644 (file)
@@ -566,7 +566,8 @@ fcloop_call_host_done(struct nvmefc_fcp_req *fcpreq,
        }
 
        /* release original io reference on tgt struct */
-       fcloop_tfcp_req_put(tfcp_req);
+       if (tfcp_req)
+               fcloop_tfcp_req_put(tfcp_req);
 }
 
 static bool drop_fabric_opcode;
@@ -671,6 +672,7 @@ fcloop_fcp_abort_recv_work(struct work_struct *work)
                break;
        default:
                spin_unlock_irqrestore(&tfcp_req->reqlock, flags);
+               fcloop_tfcp_req_put(tfcp_req);
                WARN_ON(1);
                return;
        }
@@ -958,8 +960,10 @@ fcloop_fcp_abort(struct nvme_fc_local_port *localport,
 
        spin_lock(&inireq->inilock);
        tfcp_req = inireq->tfcp_req;
-       if (tfcp_req)
-               fcloop_tfcp_req_get(tfcp_req);
+       if (tfcp_req) {
+               if (!fcloop_tfcp_req_get(tfcp_req))
+                       tfcp_req = NULL;
+       }
        spin_unlock(&inireq->inilock);
 
        if (!tfcp_req)