summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qedf/qedf_els.c
diff options
context:
space:
mode:
authorHannes Reinecke2019-03-26 08:38:49 +0100
committerMartin K. Petersen2019-03-28 02:54:53 +0100
commit56efc304b18cbfa4a2b355c0ae817f61acea38c4 (patch)
tree3d07b1605b8dcb121ee71eaa655bcb5f469e9180 /drivers/scsi/qedf/qedf_els.c
parentscsi: qedf: Add missing return in qedf_scsi_done() (diff)
downloadkernel-qcow2-linux-56efc304b18cbfa4a2b355c0ae817f61acea38c4.tar.gz
kernel-qcow2-linux-56efc304b18cbfa4a2b355c0ae817f61acea38c4.tar.xz
kernel-qcow2-linux-56efc304b18cbfa4a2b355c0ae817f61acea38c4.zip
scsi: qedf: fc_rport_priv reference counting fixes
The fc_rport_priv structure is reference counted, so we need to ensure that the reference is increased before accessing the structure. Signed-off-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Saurav Kashyap <skashyap@marvell.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/qedf/qedf_els.c')
-rw-r--r--drivers/scsi/qedf/qedf_els.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/scsi/qedf/qedf_els.c b/drivers/scsi/qedf/qedf_els.c
index f1f576375de4..1781e732d24a 100644
--- a/drivers/scsi/qedf/qedf_els.c
+++ b/drivers/scsi/qedf/qedf_els.c
@@ -378,12 +378,18 @@ void qedf_restart_rport(struct qedf_rport *fcport)
spin_unlock_irqrestore(&fcport->rport_lock, flags);
rdata = fcport->rdata;
- if (rdata) {
+ if (rdata && !kref_get_unless_zero(&rdata->kref)) {
+ fcport->rdata = NULL;
+ rdata = NULL;
+ }
+
+ if (rdata && rdata->rp_state == RPORT_ST_READY) {
lport = fcport->qedf->lport;
port_id = rdata->ids.port_id;
QEDF_ERR(&(fcport->qedf->dbg_ctx),
"LOGO port_id=%x.\n", port_id);
fc_rport_logoff(rdata);
+ kref_put(&rdata->kref, fc_rport_destroy);
mutex_lock(&lport->disc.disc_mutex);
/* Recreate the rport and log back in */
rdata = fc_rport_create(lport, port_id);
@@ -393,6 +399,7 @@ void qedf_restart_rport(struct qedf_rport *fcport)
fcport->rdata = rdata;
} else {
mutex_unlock(&lport->disc.disc_mutex);
+ fcport->rdata = NULL;
}
}
clear_bit(QEDF_RPORT_IN_RESET, &fcport->flags);