Skip to content

Commit ddb9514

Browse files
author
Nicholas Bellinger
committed
qla2xxx: Fix qlt_lport_register base_vha callback race
This patch closes a race between qlt_lport_register() and tcm_qla2xxx callback logic by holding qla_tgt_mutex before making the callback. In order for this to work, the qlt_add_target() and qlt_remove_target() code has been changed to avoid the accessing qla_tgt_mutex + list_[add,del] for NPIV enabled ports. This bug introduced in v3.14-rc1 code with commit 49a47f2. Cc: Sawan Chandak <sawan.chandak@qlogic.com> Cc: Quinn Tran <quinn.tran@qlogic.com> Cc: Saurav Kashyap <saurav.kashyap@qlogic.com> Cc: Giridhar Malavali <giridhar.malavali@qlogic.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
1 parent d6a65fd commit ddb9514

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

drivers/scsi/qla2xxx/qla_target.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4181,6 +4181,9 @@ int qlt_add_target(struct qla_hw_data *ha, struct scsi_qla_host *base_vha)
41814181
tgt->datasegs_per_cmd = QLA_TGT_DATASEGS_PER_CMD_24XX;
41824182
tgt->datasegs_per_cont = QLA_TGT_DATASEGS_PER_CONT_24XX;
41834183

4184+
if (base_vha->fc_vport)
4185+
return 0;
4186+
41844187
mutex_lock(&qla_tgt_mutex);
41854188
list_add_tail(&tgt->tgt_list_entry, &qla_tgt_glist);
41864189
mutex_unlock(&qla_tgt_mutex);
@@ -4194,6 +4197,10 @@ int qlt_remove_target(struct qla_hw_data *ha, struct scsi_qla_host *vha)
41944197
if (!vha->vha_tgt.qla_tgt)
41954198
return 0;
41964199

4200+
if (vha->fc_vport) {
4201+
qlt_release(vha->vha_tgt.qla_tgt);
4202+
return 0;
4203+
}
41974204
mutex_lock(&qla_tgt_mutex);
41984205
list_del(&vha->vha_tgt.qla_tgt->tgt_list_entry);
41994206
mutex_unlock(&qla_tgt_mutex);
@@ -4265,6 +4272,12 @@ int qlt_lport_register(void *target_lport_ptr, u64 phys_wwpn,
42654272
spin_unlock_irqrestore(&ha->hardware_lock, flags);
42664273
continue;
42674274
}
4275+
if (tgt->tgt_stop) {
4276+
pr_debug("MODE_TARGET in shutdown on qla2xxx(%d)\n",
4277+
host->host_no);
4278+
spin_unlock_irqrestore(&ha->hardware_lock, flags);
4279+
continue;
4280+
}
42684281
spin_unlock_irqrestore(&ha->hardware_lock, flags);
42694282

42704283
if (!scsi_host_get(host)) {
@@ -4279,12 +4292,11 @@ int qlt_lport_register(void *target_lport_ptr, u64 phys_wwpn,
42794292
scsi_host_put(host);
42804293
continue;
42814294
}
4282-
mutex_unlock(&qla_tgt_mutex);
4283-
42844295
rc = (*callback)(vha, target_lport_ptr, npiv_wwpn, npiv_wwnn);
42854296
if (rc != 0)
42864297
scsi_host_put(host);
42874298

4299+
mutex_unlock(&qla_tgt_mutex);
42884300
return rc;
42894301
}
42904302
mutex_unlock(&qla_tgt_mutex);

0 commit comments

Comments
 (0)