Skip to content

Commit 1668e3b

Browse files
Luojiaxing1991martinkpetersen
authored andcommitted
scsi: hisi_sas: Move evaluation of hisi_hba in hisi_sas_task_prep()
In evaluating hisi_hba, the sas_port may be NULL, so for safety relocate the the check to value possible NULL deference. Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com> Signed-off-by: John Garry <john.garry@huawei.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 5a54691 commit 1668e3b

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
@@ -287,13 +287,13 @@ static int hisi_sas_task_prep(struct sas_task *task,
287287
int *pass)
288288
{
289289
struct domain_device *device = task->dev;
290-
struct hisi_hba *hisi_hba = dev_to_hisi_hba(device);
290+
struct hisi_hba *hisi_hba;
291291
struct hisi_sas_device *sas_dev = device->lldd_dev;
292292
struct hisi_sas_port *port;
293293
struct hisi_sas_slot *slot;
294294
struct hisi_sas_cmd_hdr *cmd_hdr_base;
295295
struct asd_sas_port *sas_port = device->port;
296-
struct device *dev = hisi_hba->dev;
296+
struct device *dev;
297297
int dlvry_queue_slot, dlvry_queue, rc, slot_idx;
298298
int n_elem = 0, n_elem_req = 0, n_elem_resp = 0;
299299
struct hisi_sas_dq *dq;
@@ -314,6 +314,9 @@ static int hisi_sas_task_prep(struct sas_task *task,
314314
return -ECOMM;
315315
}
316316

317+
hisi_hba = dev_to_hisi_hba(device);
318+
dev = hisi_hba->dev;
319+
317320
if (DEV_IS_GONE(sas_dev)) {
318321
if (sas_dev)
319322
dev_info(dev, "task prep: device %d not ready\n",

0 commit comments

Comments
 (0)