Skip to contentSkip to conversation

scsi: hisi_sas: add null check before indirect pointer dereference

PATCH Applied Gustavo A. R. Silva 3 participants 3 messages May 22, 2017 – May 24, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: hisi_sas: add null check before indirect pointer dereference

Add null check before indirectly dereferencing pointer task->lldd_task in statement u32 tag = slot->idx;

Addresses-Coverity-ID: 1373843

---
 drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +1 -1
index d622db5..f720d3c 100644
@@ -963,7 +963,7 @@ static int hisi_sas_abort_task(struct sas_task *task)
 						     HISI_SAS_INT_ABT_DEV, 0);
 			rc = hisi_sas_softreset_ata_disk(device);
 		}
-	} else if (task->task_proto & SAS_PROTOCOL_SMP) {
+	} else if (task->lldd_task && task->task_proto & SAS_PROTOCOL_SMP) {
 		/* SMP */
 		struct hisi_sas_slot *slot = task->lldd_task;
 		u32 tag = slot->idx;
Signature · 1 line
2.5.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Gustavo A. R. Silva

Add null check before indirectly dereferencing pointer task->lldd_task in statement u32 tag = slot->idx;

I don't think that this is a valid scenario, but protecting against a possible NULL dereference is prudent. Thanks

Quoted 2 lines

Addresses-Coverity-ID: 1373843

#2 lore raw
In reply to Gustavo A. R. Silva

Gustavo A.,

Quoted 2 lines

Add null check before indirectly dereferencing pointer task->lldd_task in statement u32 tag = slot->idx;

Applied to 4.13/scsi-queue. Thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering