]> git.baikalelectronics.ru Git - kernel.git/commit
scsi: hisi_sas: Fix NULL pointer dereference
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Thu, 18 Oct 2018 16:59:39 +0000 (18:59 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 19 Oct 2018 22:27:49 +0000 (18:27 -0400)
commit2312ad2506b5fa799823aa32eae400cbc6812c75
tree8c236640b2e13c82240ff40109a9b9ccc4e2d17d
parent0de71fbc0898d0754c48365c8671cb7d5b5b5f9f
scsi: hisi_sas: Fix NULL pointer dereference

There is a NULL pointer dereference in case *slot* happens to be NULL at
lines 1053 and 1878:

struct hisi_sas_cq *cq =
&hisi_hba->cq[slot->dlvry_queue];

Notice that *slot* is being NULL checked at lines 1057 and 1881:
if (slot), which implies it may be NULL.

Fix this by placing the declaration and definition of variable cq, which
contains the pointer dereference slot->dlvry_queue, after slot has been
properly NULL checked.

Addresses-Coverity-ID: 1474515 ("Dereference before null check")
Addresses-Coverity-ID: 1474520 ("Dereference before null check")
Fixes: 408bae015900 ("scsi: hisi_sas: Fix the race between IO completion and timeout for SMP/internal IO")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/hisi_sas/hisi_sas_main.c