]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
scsi: hisi_sas: Fix to only call scsi_get_prot_op() for non-NULL scsi_cmnd
authorJohn Garry <john.garry@huawei.com>
Fri, 25 Jan 2019 14:22:38 +0000 (22:22 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 29 Jan 2019 06:41:20 +0000 (01:41 -0500)
A NULL-pointer dereference was introduced for TMF SSP commands from the
upstreaming reworking.

Fix this by relocating the scsi_get_prot_op() callsite.

Fixes: d6a9000b81be ("scsi: hisi_sas: Add support for DIF feature for v2 hw")
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c

index f1009e27d9bcbdecb471c56a04c954422d42146c..108683b0a049cf192a08a071dee050fd7fb212da 100644 (file)
@@ -1035,8 +1035,8 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba,
        struct sas_ssp_task *ssp_task = &task->ssp_task;
        struct scsi_cmnd *scsi_cmnd = ssp_task->cmd;
        struct hisi_sas_tmf_task *tmf = slot->tmf;
-       unsigned char prot_op = scsi_get_prot_op(scsi_cmnd);
        int has_data = 0, priority = !!tmf;
+       unsigned char prot_op;
        u8 *buf_cmd;
        u32 dw1 = 0, dw2 = 0, len = 0;
 
@@ -1051,6 +1051,7 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba,
                dw1 |= 2 << CMD_HDR_FRAME_TYPE_OFF;
                dw1 |= DIR_NO_DATA << CMD_HDR_DIR_OFF;
        } else {
+               prot_op = scsi_get_prot_op(scsi_cmnd);
                dw1 |= 1 << CMD_HDR_FRAME_TYPE_OFF;
                switch (scsi_cmnd->sc_data_direction) {
                case DMA_TO_DEVICE: