[PATCH v2 16/20] scsi: ibmvfc: fix NVMe local port leak on fabric link bounce
From: Tyrel Datwyler
Date: Fri Sep 18 2026 - 21:37:35 EST
When the fabric link goes down, ibmvfc_link_down() does not call
ibmvfc_nvme_unregister(), so vhost->nvme_local_port remains set across
the link bounce. When the adapter re-initializes and completes fabric
login, ibmvfc_nvme_register() is called again unconditionally.
nvme_fc_register_localport() finds the still-live port in the transport's
list (FC_OBJSTATE_ONLINE) and returns -EEXIST, writing NULL into
*portptr. The original local port is now orphaned in the transport with
no way to reach it, while vhost->nvme_local_port is NULL, leaving NVMe
functionality permanently broken for the lifetime of the adapter.
Fix by unregistering any existing local port at the top of
ibmvfc_nvme_register() before attempting to register a new one.
ibmvfc_nvme_register() is called from ibmvfc_do_work() with host_lock
dropped, so ibmvfc_nvme_unregister()'s wait_for_completion() is safe
there. This makes ibmvfc_nvme_register() idempotent across link bounces
without requiring changes to the link-down path.
Fixes: 3831863f9f56 ("scsi: ibmvfc: register local nvme fc port after fabric login")
Signed-off-by: Tyrel Datwyler <tyreld@xxxxxxxxxxxxx>
---
drivers/scsi/ibmvscsi/ibmvfc-nvme.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/scsi/ibmvscsi/ibmvfc-nvme.c b/drivers/scsi/ibmvscsi/ibmvfc-nvme.c
index 475177cda103..89ad7680beb4 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc-nvme.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc-nvme.c
@@ -537,6 +537,10 @@ int ibmvfc_nvme_register(struct ibmvfc_host *vhost)
if (!IS_ENABLED(CONFIG_NVME_FC))
return 0;
+ /* Unregister any stale local port left from a previous link-up */
+ if (vhost->nvme_local_port)
+ ibmvfc_nvme_unregister(vhost);
+
pinfo.node_name = fc_host_node_name(vhost->host);
pinfo.port_name = fc_host_port_name(vhost->host);
pinfo.port_id = fc_host_port_id(vhost->host);
--
2.55.0