From patchwork Tue Sep 1 11:13:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 248870 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp4318045ilg; Tue, 1 Sep 2020 07:57:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRDAnDcyu0wVWRCipgnTNnkYLhlrQP3anzhYjFjLyA/alkriqGbhRN+DIKcPZBXpcM3FZk X-Received: by 2002:a17:906:829a:: with SMTP id h26mr1875164ejx.11.1598972244634; Tue, 01 Sep 2020 07:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598972244; cv=none; d=google.com; s=arc-20160816; b=b4fctGQW8nbR7OkNbRz/+pQT4rPLQ7LQwUIzJZjBb4F1X8O5eVtNj/Rd8QzRbthZV0 yO4EOn9uhIXfjvkkaDT/l9Z7GWv5GoJMZt8Eddz0YVfqqJHFvY855cIrpJzjQa2YAnbw j2rRI3Y50CEOHtMneJngx0p3Sdr29v+0R8rGdjFomC8sItSuvJmZx9LDJk1jhc8bokbj ikqMbTYrqIXc2r7mjJRGJPrsvt+TL41LuElOdOoRiSs9dIXopHGHtk2H50hszcof0F88 ZMbFVHiGezQdFAYJdRcAU5GTVxKbYm6NEJ7RvK8cNmeXn3sA91Q+DKhJiE9Z6HjMf+Eb GqaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=NKrxG679GL/DSJIoGLgByhmUm9rLGwsOW8E5+17YJls=; b=a7SJTwGAwGzqnGOZz5ca14JP433otEi71jSFEIrARh/Kpt20STLPVpfEp/21zklX7t eVcMgNFSyml0+BVDYXzMXY0suCnZRjQwZ+HUszgqx0qiFpY+EujxwHPd7q8yJpXL3xTU F1aEKBel8vKyswx8DTOuWQfc84QiTGbiS+TExaWwMbARQMHAoqEcFoFWGSTESgb3TmjJ 8k6tqYrIo0+NkOW6MlLhaHWXIH82zZyKZm29rhMckpAtZw6AWoJJ7ZgYDNuxTp3GRVLy WL88DSboURvu95gFr71ckeCUIvZzZ7NG0RsY37MiXKMzwBv2RDEIwhB9Y7HY9hdJdszo GYJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h6si802550ejc.567.2020.09.01.07.57.24 for ; Tue, 01 Sep 2020 07:57:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728876AbgIAOzM (ORCPT ); Tue, 1 Sep 2020 10:55:12 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:44770 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726984AbgIALeb (ORCPT ); Tue, 1 Sep 2020 07:34:31 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 41B54EC1076991CB71A6; Tue, 1 Sep 2020 19:17:07 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Tue, 1 Sep 2020 19:16:58 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 1/8] scsi: hisi_sas: Avoid accessing to SSP task for SMP IOs Date: Tue, 1 Sep 2020 19:13:03 +0800 Message-ID: <1598958790-232272-2-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1598958790-232272-1-git-send-email-john.garry@huawei.com> References: <1598958790-232272-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Xiang Chen In function hisi_sas_slot_task_free(), it accesses to SSP task for non-ATA task. But if it is SMP task here, it accesses to wrong structure though it may not cause any issue. To avoid it, only access to ssp task when slot->n_elem_dif is not 0 which indicates this is SSP task. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) -- 2.26.2 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 11caa4b0d797..fdf5f0f1b60b 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -229,17 +229,18 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task, task->lldd_task = NULL; if (!sas_protocol_ata(task->task_proto)) { - struct sas_ssp_task *ssp_task = &task->ssp_task; - struct scsi_cmnd *scsi_cmnd = ssp_task->cmd; - if (slot->n_elem) dma_unmap_sg(dev, task->scatter, task->num_scatter, task->data_dir); - if (slot->n_elem_dif) + if (slot->n_elem_dif) { + struct sas_ssp_task *ssp_task = &task->ssp_task; + struct scsi_cmnd *scsi_cmnd = ssp_task->cmd; + dma_unmap_sg(dev, scsi_prot_sglist(scsi_cmnd), scsi_prot_sg_count(scsi_cmnd), task->data_dir); + } } }