Commit 85bbe13b authored by Yihang Li's avatar Yihang Li Committed by JiangShui
Browse files

scsi: hisi_sas: Check before using pointer variables

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8IL6H


CVE: NA

----------------------------------------------------------------------

In commit 4b329abc ("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: 4b329abc ("scsi: hisi_sas: Move slot variable definition in hisi_sas_abort_task()")
Signed-off-by: default avatarYihang Li <liyihang9@huawei.com>
Signed-off-by: default avatarXiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: default avatarxiabing <xiabing12@h-partners.com>
parent a132be50
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -1741,7 +1741,10 @@ static int hisi_sas_abort_task(struct sas_task *task)
	task->task_state_flags |= SAS_TASK_STATE_ABORTED;
	spin_unlock_irqrestore(&task->task_state_lock, flags);

	if (slot && task->task_proto & SAS_PROTOCOL_SSP) {
	if (!slot)
		goto out;

	if (task->task_proto & SAS_PROTOCOL_SSP) {
		struct scsi_cmnd *cmnd = task->uldd_task;
		u16 tag = slot->idx;
		int rc2;
@@ -1798,7 +1801,7 @@ static int hisi_sas_abort_task(struct sas_task *task)
				rc = hisi_sas_softreset_ata_disk(device);
			}
		}
	} else if (slot && task->task_proto & SAS_PROTOCOL_SMP) {
	} else if (task->task_proto & SAS_PROTOCOL_SMP) {
		/* SMP */
		u32 tag = slot->idx;
		struct hisi_sas_cq *cq = &hisi_hba->cq[slot->dlvry_queue];