Commit 7867b98d authored by himanshu.madhani@cavium.com's avatar himanshu.madhani@cavium.com Committed by Martin K. Petersen

scsi: qla2xxx: Fix memory leak in dual/target mode

When driver is loaded in Target/Dual mode, it creates QPair to support
MQ and allocates resources for each QPair. This Qpair initialization is
delayed until the FW personality is changed to Dual/Target mode by
issuing chip reset. At the time of chip reset firmware is re-initilized
in correct personality all the QPairs are initialized by sending
MBC_INITIALIZE_MULTIQ (001Fh).

This patch fixes memory leak by adding check to issue
MBC_INITIALIZE_MULTIQ command only while deleting rsp/req queue when the
flag is set for initiator mode, and clean up QPair resources correctly
during the driver unload. This MBX does not need to be issued for
Target/Dual mode because chip reset will reset ISP.

Fixes: d65237c7 ("scsi: qla2xxx: Fix mailbox failure while deleting Queue pairs")
Cc: <stable@vger.kernel.org> # 4.10+
Signed-off-by: default avatarHimanshu Madhani <himanshu.madhani@cavium.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 19759033
...@@ -8220,9 +8220,6 @@ int qla2xxx_delete_qpair(struct scsi_qla_host *vha, struct qla_qpair *qpair) ...@@ -8220,9 +8220,6 @@ int qla2xxx_delete_qpair(struct scsi_qla_host *vha, struct qla_qpair *qpair)
int ret = QLA_FUNCTION_FAILED; int ret = QLA_FUNCTION_FAILED;
struct qla_hw_data *ha = qpair->hw; struct qla_hw_data *ha = qpair->hw;
if (!vha->flags.qpairs_req_created && !vha->flags.qpairs_rsp_created)
goto fail;
qpair->delete_in_progress = 1; qpair->delete_in_progress = 1;
while (atomic_read(&qpair->ref_count)) while (atomic_read(&qpair->ref_count))
msleep(500); msleep(500);
...@@ -8230,6 +8227,7 @@ int qla2xxx_delete_qpair(struct scsi_qla_host *vha, struct qla_qpair *qpair) ...@@ -8230,6 +8227,7 @@ int qla2xxx_delete_qpair(struct scsi_qla_host *vha, struct qla_qpair *qpair)
ret = qla25xx_delete_req_que(vha, qpair->req); ret = qla25xx_delete_req_que(vha, qpair->req);
if (ret != QLA_SUCCESS) if (ret != QLA_SUCCESS)
goto fail; goto fail;
ret = qla25xx_delete_rsp_que(vha, qpair->rsp); ret = qla25xx_delete_rsp_que(vha, qpair->rsp);
if (ret != QLA_SUCCESS) if (ret != QLA_SUCCESS)
goto fail; goto fail;
......
...@@ -575,13 +575,14 @@ qla25xx_free_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp) ...@@ -575,13 +575,14 @@ qla25xx_free_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp)
int int
qla25xx_delete_req_que(struct scsi_qla_host *vha, struct req_que *req) qla25xx_delete_req_que(struct scsi_qla_host *vha, struct req_que *req)
{ {
int ret = -1; int ret = QLA_SUCCESS;
if (req) { if (req && vha->flags.qpairs_req_created) {
req->options |= BIT_0; req->options |= BIT_0;
ret = qla25xx_init_req_que(vha, req); ret = qla25xx_init_req_que(vha, req);
if (ret != QLA_SUCCESS)
return QLA_FUNCTION_FAILED;
} }
if (ret == QLA_SUCCESS)
qla25xx_free_req_que(vha, req); qla25xx_free_req_que(vha, req);
return ret; return ret;
...@@ -590,13 +591,14 @@ qla25xx_delete_req_que(struct scsi_qla_host *vha, struct req_que *req) ...@@ -590,13 +591,14 @@ qla25xx_delete_req_que(struct scsi_qla_host *vha, struct req_que *req)
int int
qla25xx_delete_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp) qla25xx_delete_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp)
{ {
int ret = -1; int ret = QLA_SUCCESS;
if (rsp) { if (rsp && vha->flags.qpairs_rsp_created) {
rsp->options |= BIT_0; rsp->options |= BIT_0;
ret = qla25xx_init_rsp_que(vha, rsp); ret = qla25xx_init_rsp_que(vha, rsp);
if (ret != QLA_SUCCESS)
return QLA_FUNCTION_FAILED;
} }
if (ret == QLA_SUCCESS)
qla25xx_free_rsp_que(vha, rsp); qla25xx_free_rsp_que(vha, rsp);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment