From patchwork Fri Jan 25 14:22:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 156596 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp417783jaa; Fri, 25 Jan 2019 06:22:32 -0800 (PST) X-Google-Smtp-Source: ALg8bN4mikzmd6B1Vn+dqtl0/qenLWeaOeitffupyqu55Lsni9EHA5b2LdZ9JdQiAoiVjnVQRIuc X-Received: by 2002:a63:c848:: with SMTP id l8mr10042548pgi.78.1548426152684; Fri, 25 Jan 2019 06:22:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548426152; cv=none; d=google.com; s=arc-20160816; b=GzZ0gn+UaRn94g5cavDxoAfVFxCIN+U6JgZLBnUhp2TxpJZtcfizwmHQO7LihQE7Yf Manu/fr9U1KtLmyr9hm2zxH6aeZ0XOFYmAg0/sZccjezXEZGrvMEvbpV7JtSDn/4PL6w E5wFQe0SbpXP73hrohgCJahgSIYFWR2BM7lIN/fLVXVYCpNievQQfeBl2yPPJoMgs6WM vAfiDVTZHAjBfOTRbO9CPyMoNck2rqOiAJKUO2jCR48gcrVPO5+jKlZ2SEWjzGtjnEvB dkpqanltb2FzVrCZGVZfBbBTmpYK20LIfQq+M0QxKJD6YKc7zpm/2bpbnZ6Q6QeLNvIi Nudg== 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=O3fftt//QpuwvpJKKLWtFfLZ3bzf9Y1OK28m694pX1s=; b=zmQPEw+3hqu9yl0AlKJtJeLzRnUyoFT8h7jbn6d8TrSUHGIkpJOAcvM+rnnnK1j5qr Hja4O+6jQfP+Ura+WHqEzjJFWFEsOqvfMbUPvb0E5+DeLZO9KacIAtmz0mSvBU/rYJWV 5M8ekHGVRBzt4iZBJntGGSDZqa+GSDtAWcbIDMLPhhMPi/km10sYNItfTmhEtlJ8nLln mNOXPWIoNDPxfJD4DY6tCQWemD0GE9OsQrUQQZqlx0T4YM52rhkO5i4OmD4XRaFsGomO /oCbwV3+YvtXBtBX/8uhJZ6OwynbK0uxYMyTGhrA07totdqt/RCeKxoDhOxSamIDkjmS 9luQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v34si24113534plg.205.2019.01.25.06.22.32; Fri, 25 Jan 2019 06:22:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728821AbfAYOWZ (ORCPT + 31 others); Fri, 25 Jan 2019 09:22:25 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:56362 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728933AbfAYOWH (ORCPT ); Fri, 25 Jan 2019 09:22:07 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 422B640F0E0E118A240A; Fri, 25 Jan 2019 22:22:04 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Fri, 25 Jan 2019 22:21:54 +0800 From: John Garry To: , CC: , , , John Garry Subject: [PATCH 12/13] scsi: hisi_sas: Fix to only call scsi_get_prot_op() for non-NULL scsi_cmnd Date: Fri, 25 Jan 2019 22:22:38 +0800 Message-ID: <1548426159-225679-13-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1548426159-225679-1-git-send-email-john.garry@huawei.com> References: <1548426159-225679-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index f1009e2..108683b 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -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: