When lpfc_vmid_uvem() or lpfc_vmid_cmd() fails in lpfc_vmid_get_appid(), the error path marks the slot LPFC_VMID_SLOT_FREE and calls free_percpu(vmp->last_io_time) without clearing vmp->last_io_time. When the slot is later reused, if (!vmp->last_io_time) skips alloc_percpu_gfp() and leaves I/O paths and lpfc_reinit_vmid() writing to the freed per-CPU pointer, followed by a double free on a subsequent failure or teardown. Clear vmp->last_io_time after free_percpu(), matching lpfc_hbadisc.c. Found by LLM-assisted static analysis. Compile-tested on x86_64. Fixes: 33c79741deaf ("scsi: lpfc: vmid: Introduce VMID in I/O path") Cc: stable@vger.kernel.org Signed-off-by: Ziheng Wei --- drivers/scsi/lpfc/lpfc_vmid.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/lpfc/lpfc_vmid.c b/drivers/scsi/lpfc/lpfc_vmid.c index 14dbfe954..a13e5a07e 100644 --- a/drivers/scsi/lpfc/lpfc_vmid.c +++ b/drivers/scsi/lpfc/lpfc_vmid.c @@ -270,6 +270,7 @@ int lpfc_vmid_get_appid(struct lpfc_vport *vport, char *uuid, hash_del(&vmp->hnode); vmp->flag = LPFC_VMID_SLOT_FREE; free_percpu(vmp->last_io_time); + vmp->last_io_time = NULL; write_unlock(&vport->vmid_lock); return -EIO; } base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa -- 2.43.0