linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: efct: reject PRLI when no target configured
@ 2022-05-31  9:28 Dmitry Bogdanov
  0 siblings, 0 replies; only message in thread
From: Dmitry Bogdanov @ 2022-05-31  9:28 UTC (permalink / raw)
  To: Martin Petersen, target-devel; +Cc: linux-scsi, linux, Dmitry Bogdanov

When target is not yet configured PRLI is ignored and consequent PLOGI
comes in the wrong state and produces WARN:
  WARNING: CPU: 25 PID: 2429 at drivers/scsi/elx/libefc/efc_device.c:350 efc_send_ls_acc_after_attach+0x20/0x58 [efct]

Reject PRLI like in other error cases when session can not be created.
And fix a memory leak of wq_data in the same place.

Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
 drivers/scsi/elx/efct/efct_lio.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/elx/efct/efct_lio.c b/drivers/scsi/elx/efct/efct_lio.c
index 9c45a0ca9191..dbe2f1871da3 100644
--- a/drivers/scsi/elx/efct/efct_lio.c
+++ b/drivers/scsi/elx/efct/efct_lio.c
@@ -1183,6 +1183,7 @@ static void efct_lio_setup_session(struct work_struct *work)
 	struct se_session *se_sess;
 	int watermark;
 	int ini_count;
+	int ret = 0;
 	u64 id;
 
 	/* Check to see if it's belongs to vport,
@@ -1196,7 +1197,8 @@ static void efct_lio_setup_session(struct work_struct *work)
 		se_tpg = &tpg->tpg;
 	} else {
 		efc_log_err(efct, "failed to init session\n");
-		return;
+		ret = -EIO;
+		goto done;
 	}
 
 	/*
@@ -1210,9 +1212,8 @@ static void efct_lio_setup_session(struct work_struct *work)
 				       node, efct_session_cb);
 	if (IS_ERR(se_sess)) {
 		efc_log_err(efct, "failed to setup session\n");
-		kfree(wq_data);
-		efc_scsi_sess_reg_complete(node, -EIO);
-		return;
+		ret = -EIO;
+		goto done;
 	}
 
 	tgt_node = node->tgt_node;
@@ -1224,8 +1225,6 @@ static void efct_lio_setup_session(struct work_struct *work)
 	if (xa_err(xa_store(&efct->lookup, id, tgt_node, GFP_KERNEL)))
 		efc_log_err(efct, "Node lookup store failed\n");
 
-	efc_scsi_sess_reg_complete(node, 0);
-
 	/* update IO watermark: increment initiator count */
 	ini_count = atomic_add_return(1, &efct->tgt_efct.initiator_count);
 	watermark = efct->tgt_efct.watermark_max -
@@ -1234,7 +1233,9 @@ static void efct_lio_setup_session(struct work_struct *work)
 			efct->tgt_efct.watermark_min : watermark;
 	atomic_set(&efct->tgt_efct.io_high_watermark, watermark);
 
+done:
 	kfree(wq_data);
+	efc_scsi_sess_reg_complete(node, ret);
 }
 
 int efct_scsi_new_initiator(struct efc *efc, struct efc_node *node)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-31  9:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-31  9:28 [PATCH] scsi: efct: reject PRLI when no target configured Dmitry Bogdanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).