[PATCH] scsi: lpfc: Look up the VMID entry under vmid_lock
From: Changyul Lee
Date: Sun Nov 15 2026 - 21:39:53 EST
lpfc_cmpl_ct_cmd_vmid() looks up the VMID entry for an RAPP_IDENT
response without vport->vmid_lock and takes the lock only after the
lookup. lpfc_vmid_get_appid() can meanwhile hash_del() another entry
from the same bucket under the lock. hash_del() clears the next pointer
of the removed node, so the walk stops early and misses the entry that
waits for the response. That entry keeps LPFC_VMID_REQ_REGISTER, and
the I/O of that VM is sent without a VMID tag from then on.
Take vmid_lock before the lookup, as lpfc_vmid_get_appid() does.
Fixes: 33c79741deaf ("scsi: lpfc: vmid: Introduce VMID in I/O path")
Signed-off-by: Changyul Lee <lcy8047@xxxxxxxxx>
---
Found with a static analysis tool we are developing.
Compile-tested only, with x86_64_defconfig plus SCSI_LPFC and W=1.
drivers/scsi/lpfc/lpfc_ct.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index f709e5087577..af720ccdf1b6 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -3613,14 +3613,13 @@ lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
hash = lpfc_vmid_hash_fn(app->obj.entity_id,
app->obj.entity_id_len);
+ write_lock(&vport->vmid_lock);
vmp = lpfc_get_vmid_from_hashtable(vport, hash,
app->obj.entity_id);
if (vmp) {
- write_lock(&vport->vmid_lock);
vmp->un.app_id = be32_to_cpu(app->app_id);
vmp->flag |= LPFC_VMID_REGISTERED;
vmp->flag &= ~LPFC_VMID_REQ_REGISTER;
- write_unlock(&vport->vmid_lock);
/* Set IN USE flag */
vport->vmid_flag |= LPFC_VMID_IN_USE;
} else {
@@ -3628,6 +3627,7 @@ lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
"6901 No entry found %s hash %d\n",
app->obj.entity_id, hash);
}
+ write_unlock(&vport->vmid_lock);
break;
case SLI_CTAS_DAPP_IDENT:
app = (struct app_id_object *)(DAPP_IDENT_OFFSET + data);
base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
--
2.43.0