Skip to content

Commit

Permalink
[SCSI] qla2xxx: Fix NULL ptr deref bug in fail path during queue create
Browse files Browse the repository at this point in the history
Current code attempts to clean up resources when queue create fails and there it
invokes queue free call with a (NULL) pointer to the queue which could not be
allocated in the first place. Fix it by returning directly without invoking the
queue free call as no resources has been allocated at that point of time.

Reported-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Anirban Chakraborty <anirban.chakraborty@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
  • Loading branch information
Anirban Chakraborty authored and James Bottomley committed Oct 2, 2009
1 parent 2c2ed8b commit c7922a9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/scsi/qla2xxx/qla_mid.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
if (req == NULL) {
qla_printk(KERN_WARNING, ha, "could not allocate memory"
"for request que\n");
goto que_failed;
goto failed;
}

req->length = REQUEST_ENTRY_CNT_24XX;
Expand Down Expand Up @@ -632,6 +632,7 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,

que_failed:
qla25xx_free_req_que(base_vha, req);
failed:
return 0;
}

Expand Down Expand Up @@ -659,7 +660,7 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
if (rsp == NULL) {
qla_printk(KERN_WARNING, ha, "could not allocate memory for"
" response que\n");
goto que_failed;
goto failed;
}

rsp->length = RESPONSE_ENTRY_CNT_MQ;
Expand Down Expand Up @@ -728,6 +729,7 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,

que_failed:
qla25xx_free_rsp_que(base_vha, rsp);
failed:
return 0;
}

Expand Down

0 comments on commit c7922a9

Please sign in to comment.