[PATCH] scsi: qedf: Free exchange manager on probe failure
From: 박명훈
Date: Mon Apr 27 2026 - 05:22:37 EST
From: Myeonghun Pak <mhun512@xxxxxxxxx>
qedf_lport_setup() allocates a libfc exchange manager that is normally
released from qedf_remove(). If probe fails after the lport setup has
completed, the driver core does not call .remove(), so the exchange
manager and lport stats are left allocated.
Release the lport resources from the probe error path and also drop the
exchange manager if stats allocation fails inside qedf_lport_setup().
Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.")
Cc: stable@xxxxxxxxxxxxxxx
Co-developed-by: Ijae Kim <ae878000@xxxxxxxxx>
Signed-off-by: Ijae Kim <ae878000@xxxxxxxxx>
Signed-off-by: Myeonghun Pak <mhun512@xxxxxxxxx>
---
drivers/scsi/qedf/qedf_main.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index da429b3a42..499d42e46c 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -1765,8 +1765,10 @@ static int qedf_lport_setup(struct qedf_ctx *qedf)
fc_exch_mgr_alloc(lport, FC_CLASS_3, FCOE_PARAMS_NUM_TASKS,
0xfffe, NULL);
- if (fc_lport_init_stats(lport))
+ if (fc_lport_init_stats(lport)) {
+ fc_exch_mgr_free(lport);
return -ENOMEM;
+ }
/* Finish lport config */
fc_lport_config(lport);
@@ -3306,6 +3308,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
struct qed_slowpath_params slowpath_params;
struct qed_probe_params qed_params;
u16 retry_cnt = 10;
+ bool lport_setup = false;
/*
* When doing error recovery we didn't reap the lport so don't try
@@ -3625,6 +3628,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
"qedf_lport_setup failed.\n");
goto err7;
}
+ lport_setup = true;
}
qedf->timer_work_queue = alloc_workqueue("qedf_%u_timer",
@@ -3704,6 +3708,10 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
destroy_workqueue(qedf->ll2_recv_wq);
fc_remove_host(qedf->lport->host);
scsi_remove_host(qedf->lport->host);
+ if (lport_setup) {
+ fc_exch_mgr_free(qedf->lport);
+ fc_lport_free_stats(qedf->lport);
+ }
#ifdef CONFIG_DEBUG_FS
qedf_dbg_host_exit(&(qedf->dbg_ctx));
#endif
--
2.50.1