Commit cf8e94b0 authored by Allen Pais's avatar Allen Pais Committed by Kelsey Skunberg

scsi: qla2xxx: fix a potential NULL pointer dereference

BugLink: https://bugs.launchpad.net/bugs/1868627

commit 35a79a63 upstream.

alloc_workqueue is not checked for errors and as a result a potential
NULL dereference could occur.

Link: https://lore.kernel.org/r/1568824618-4366-1-git-send-email-allen.pais@oracle.comSigned-off-by: default avatarAllen Pais <allen.pais@oracle.com>
Reviewed-by: default avatarMartin Wilck <mwilck@suse.com>
Acked-by: default avatarHimanshu Madhani <hmadhani@marvell.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
[Ajay: Rewrote this patch for v4.4.y, as 4.4.y codebase is different from mainline]
Signed-off-by: default avatarAjay Kaher <akaher@vmware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarKelsey Skunberg <kelsey.skunberg@canonical.com>
parent 3bb02a11
...@@ -441,6 +441,12 @@ static int qla25xx_setup_mode(struct scsi_qla_host *vha) ...@@ -441,6 +441,12 @@ static int qla25xx_setup_mode(struct scsi_qla_host *vha)
goto fail; goto fail;
} }
if (ql2xmultique_tag) { if (ql2xmultique_tag) {
ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 1);
if (unlikely(!ha->wq)) {
ql_log(ql_log_warn, vha, 0x01e0,
"Failed to alloc workqueue.\n");
goto fail;
}
/* create a request queue for IO */ /* create a request queue for IO */
options |= BIT_7; options |= BIT_7;
req = qla25xx_create_req_que(ha, options, 0, 0, -1, req = qla25xx_create_req_que(ha, options, 0, 0, -1,
...@@ -448,9 +454,8 @@ static int qla25xx_setup_mode(struct scsi_qla_host *vha) ...@@ -448,9 +454,8 @@ static int qla25xx_setup_mode(struct scsi_qla_host *vha)
if (!req) { if (!req) {
ql_log(ql_log_warn, vha, 0x00e0, ql_log(ql_log_warn, vha, 0x00e0,
"Failed to create request queue.\n"); "Failed to create request queue.\n");
goto fail; goto fail2;
} }
ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 1);
vha->req = ha->req_q_map[req]; vha->req = ha->req_q_map[req];
options |= BIT_1; options |= BIT_1;
for (ques = 1; ques < ha->max_rsp_queues; ques++) { for (ques = 1; ques < ha->max_rsp_queues; ques++) {
...@@ -458,7 +463,7 @@ static int qla25xx_setup_mode(struct scsi_qla_host *vha) ...@@ -458,7 +463,7 @@ static int qla25xx_setup_mode(struct scsi_qla_host *vha)
if (!ret) { if (!ret) {
ql_log(ql_log_warn, vha, 0x00e8, ql_log(ql_log_warn, vha, 0x00e8,
"Failed to create response queue.\n"); "Failed to create response queue.\n");
goto fail2; goto fail3;
} }
} }
ha->flags.cpu_affinity_enabled = 1; ha->flags.cpu_affinity_enabled = 1;
...@@ -472,11 +477,13 @@ static int qla25xx_setup_mode(struct scsi_qla_host *vha) ...@@ -472,11 +477,13 @@ static int qla25xx_setup_mode(struct scsi_qla_host *vha)
ha->max_rsp_queues, ha->max_req_queues); ha->max_rsp_queues, ha->max_req_queues);
} }
return 0; return 0;
fail2:
fail3:
qla25xx_delete_queues(vha); qla25xx_delete_queues(vha);
destroy_workqueue(ha->wq);
ha->wq = NULL;
vha->req = ha->req_q_map[0]; vha->req = ha->req_q_map[0];
fail2:
destroy_workqueue(ha->wq);
ha->wq = NULL;
fail: fail:
ha->mqenable = 0; ha->mqenable = 0;
kfree(ha->req_q_map); kfree(ha->req_q_map);
......
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