scsi: lpfc: sanity check hrq is null before dereferencing it

From: Colin Ian King <colin.king@canonical.com>

The sanity check for hrq should be moved to before the deference
of hrq to ensure we don't perform a null pointer deference.

Detected by CoverityScan, CID#1411650 ("Dereference before null check")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
James Smart 2017-03-04 09:30:22 -08:00 committed by Martin K. Petersen
parent 70e5afd57d
commit 7aabe84b8a
1 changed files with 5 additions and 5 deletions

View File

@ -15185,17 +15185,17 @@ lpfc_mrq_create(struct lpfc_hba *phba, struct lpfc_queue **hrqp,
drq = drqp[idx]; drq = drqp[idx];
cq = cqp[idx]; cq = cqp[idx];
if (hrq->entry_count != drq->entry_count) {
status = -EINVAL;
goto out;
}
/* sanity check on queue memory */ /* sanity check on queue memory */
if (!hrq || !drq || !cq) { if (!hrq || !drq || !cq) {
status = -ENODEV; status = -ENODEV;
goto out; goto out;
} }
if (hrq->entry_count != drq->entry_count) {
status = -EINVAL;
goto out;
}
if (idx == 0) { if (idx == 0) {
bf_set(lpfc_mbx_rq_create_num_pages, bf_set(lpfc_mbx_rq_create_num_pages,
&rq_create->u.request, &rq_create->u.request,