summaryrefslogtreecommitdiff
path: root/drivers/scsi/qedf/qedf_els.c
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.com>2019-03-26 10:38:49 +0300
committerMartin K. Petersen <martin.petersen@oracle.com>2019-03-28 04:54:53 +0300
commit56efc304b18cbfa4a2b355c0ae817f61acea38c4 (patch)
tree3d07b1605b8dcb121ee71eaa655bcb5f469e9180 /drivers/scsi/qedf/qedf_els.c
parent6f15d0c02950c75f85542031ccbf6a9725ca9925 (diff)
downloadlinux-56efc304b18cbfa4a2b355c0ae817f61acea38c4.tar.xz
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);