]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
nvmet-fc: abort command when there is no binding
authorDaniel Wagner <dwagner@suse.de>
Wed, 31 Jan 2024 08:51:09 +0000 (09:51 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Mar 2024 12:16:45 +0000 (13:16 +0100)
[ Upstream commit 3146345c2e9c2f661527054e402b0cfad80105a4 ]

When the target port has not active port binding, there is no point in
trying to process the command as it has to fail anyway. Instead adding
checks to all commands abort the command early.

Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/target/fc.c

index 18a64a4fd8da90bd1e830b12d262405a5b3d5325..846fb41da64304ead92e56bdf089df92babb1dbe 100644 (file)
@@ -1102,6 +1102,9 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle)
        int idx;
        bool needrandom = true;
 
+       if (!tgtport->pe)
+               return NULL;
+
        assoc = kzalloc(sizeof(*assoc), GFP_KERNEL);
        if (!assoc)
                return NULL;
@@ -2529,8 +2532,9 @@ nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport,
 
        fod->req.cmd = &fod->cmdiubuf.sqe;
        fod->req.cqe = &fod->rspiubuf.cqe;
-       if (tgtport->pe)
-               fod->req.port = tgtport->pe->port;
+       if (!tgtport->pe)
+               goto transport_error;
+       fod->req.port = tgtport->pe->port;
 
        /* clear any response payload */
        memset(&fod->rspiubuf, 0, sizeof(fod->rspiubuf));