Skip to content

Commit 8dd1029

Browse files
Yihang Limartinkpetersen
authored andcommitted
scsi: hisi_sas: Check before using pointer variables
In commit 4b329ab ("scsi: hisi_sas: Move slot variable definition in hisi_sas_abort_task()"), we move the variables slot to the function head. However, the variable slot may be NULL, we should check it in each branch. Fixes: 4b329ab ("scsi: hisi_sas: Move slot variable definition in hisi_sas_abort_task()") Signed-off-by: Yihang Li <[email protected]> Signed-off-by: Xiang Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent d34ee53 commit 8dd1029

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/scsi/hisi_sas/hisi_sas_main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,10 @@ static int hisi_sas_abort_task(struct sas_task *task)
16411641
task->task_state_flags |= SAS_TASK_STATE_ABORTED;
16421642
spin_unlock_irqrestore(&task->task_state_lock, flags);
16431643

1644-
if (slot && task->task_proto & SAS_PROTOCOL_SSP) {
1644+
if (!slot)
1645+
goto out;
1646+
1647+
if (task->task_proto & SAS_PROTOCOL_SSP) {
16451648
u16 tag = slot->idx;
16461649
int rc2;
16471650

@@ -1688,7 +1691,7 @@ static int hisi_sas_abort_task(struct sas_task *task)
16881691
rc = hisi_sas_softreset_ata_disk(device);
16891692
}
16901693
}
1691-
} else if (slot && task->task_proto & SAS_PROTOCOL_SMP) {
1694+
} else if (task->task_proto & SAS_PROTOCOL_SMP) {
16921695
/* SMP */
16931696
u32 tag = slot->idx;
16941697
struct hisi_sas_cq *cq = &hisi_hba->cq[slot->dlvry_queue];

0 commit comments

Comments
 (0)