summaryrefslogtreecommitdiff
path: root/drivers/scsi/qedf
diff options
context:
space:
mode:
authorSaurav Kashyap <skashyap@marvell.com>2019-03-26 10:38:56 +0300
committerMartin K. Petersen <martin.petersen@oracle.com>2019-03-28 04:54:53 +0300
commitfe2043d19e4a10fd697756ca6edf0edc1c0392ef (patch)
tree8689a3330aed705302efc2beea9488bc46e6e814 /drivers/scsi/qedf
parentfaea5719d373f38d785961ee724de1b392e869e8 (diff)
downloadlinux-fe2043d19e4a10fd697756ca6edf0edc1c0392ef.tar.xz
scsi: qedf: Correctly handle refcounting of rdata
- Handle refcount of rdata during error conditions. Signed-off-by: Saurav Kashyap <skashyap@marvell.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/qedf')
-rw-r--r--drivers/scsi/qedf/qedf_io.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c
index db5d49e72652..b359ae3b78b5 100644
--- a/drivers/scsi/qedf/qedf_io.c
+++ b/drivers/scsi/qedf/qedf_io.c
@@ -2241,7 +2241,6 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,
unsigned long flags;
struct fcoe_wqe *sqe;
u16 sqe_idx;
- struct fc_rport_priv *rdata = fcport->rdata;
if (!sc_cmd) {
QEDF_ERR(&(qedf->dbg_ctx), "invalid arg\n");
@@ -2252,22 +2251,14 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,
if (!test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags)) {
QEDF_ERR(&(qedf->dbg_ctx), "fcport not offloaded\n");
rc = FAILED;
- return FAILED;
- }
-
- if (!rdata || !kref_get_unless_zero(&rdata->kref)) {
- QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_SCSI_TM, "stale rport\n");
- return FAILED;
+ goto no_flush;
}
- QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_SCSI_TM,
- "portid = 0x%x tm_flags = %d\n",
- rdata->ids.port_id, tm_flags);
io_req = qedf_alloc_cmd(fcport, QEDF_TASK_MGMT_CMD);
if (!io_req) {
QEDF_ERR(&(qedf->dbg_ctx), "Failed TMF");
rc = -EAGAIN;
- goto reset_tmf_err;
+ goto no_flush;
}
if (tm_flags == FCP_TMF_LUN_RESET)
@@ -2356,8 +2347,6 @@ no_flush:
QEDF_ERR(&(qedf->dbg_ctx), "task mgmt command success...\n");
rc = SUCCESS;
}
-reset_tmf_err:
- kref_put(&rdata->kref, fc_rport_destroy);
return rc;
}
@@ -2405,7 +2394,7 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
rc = fc_block_scsi_eh(sc_cmd);
if (rc)
- return rc;
+ goto tmf_err;
if (!fcport) {
QEDF_ERR(NULL, "device_reset: rport is NULL\n");
@@ -2442,7 +2431,13 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
}
if (test_bit(QEDF_RPORT_UPLOADING_CONNECTION, &fcport->flags)) {
- QEDF_ERR(&qedf->dbg_ctx, "fcport is uploading.\n");
+ if (!fcport->rdata)
+ QEDF_ERR(&qedf->dbg_ctx, "fcport %p is uploading.\n",
+ fcport);
+ else
+ QEDF_ERR(&qedf->dbg_ctx,
+ "fcport %p port_id=%06x is uploading.\n",
+ fcport, fcport->rdata->ids.port_id);
rc = FAILED;
goto tmf_err;
}
@@ -2450,6 +2445,7 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
rc = qedf_execute_tmf(fcport, sc_cmd, tm_flags);
tmf_err:
+ kref_put(&rdata->kref, fc_rport_destroy);
return rc;
}