From patchwork Mon May 6 14:32:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 163407 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:81:0:0:0:0 with SMTP id l1csp52614ilm; Mon, 6 May 2019 07:37:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTVAXuzq50U4l9ppEK56UzgbLtum8LW4P4pjq3siGFMou4N4tndpmaednQQUvrvncYfulr X-Received: by 2002:a17:902:5983:: with SMTP id p3mr1052110pli.224.1557153450236; Mon, 06 May 2019 07:37:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557153450; cv=none; d=google.com; s=arc-20160816; b=1Iwnlbsl+meK2t/lFN7B0p/EmbTa0//8z9LLtwkmd3W3PP9dnoPfV0hypjCy7xxsxj 3JvtLLNNwel35/xcmBM/IeCGrcyTq7H0ZZXyk48M+MBClRNc05/u/qwlJKzN/obj1Te0 JlHCkSYRkvbhG+EDygyF6d0CeLJ+9NuDEYW8NPUsZlRAlDDwbbYR6LFn6UQ381hPSemm H3X7tQCza1h//CfusFi/Zv1TVzL5X1rNhbKPBP1WFTLziewRlrxh+13Tml+eMOkKxk4y w9UH3ztoqQAd1Fhr68qt4UWF02b1NCvxHG+j94/kE1mKWZfAGjc1a2Uly2WMD0NVqStd gFvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UQL++v6qSObdc8OzDbGlgMTE+LrGxeZSbegmQsRzBQA=; b=cXW3UfaKXcuUI9KQ9jE5JCnTIbPyDQsWNnD1ThO5PlpXtMwjHIvDesUD0lWHH4dS67 FWHO7sNb8v6fyjB2HqzYrB3M0Fw1e13a52V08vDLFthaA/mYilACySDe0pi0S2l8s27Z dFyK9lG6+ZqoDM2TPQf9/8eSZrJBdwn9SjkF/De6WnZV67diswjixtYNie1oTUHY9i0N Z+gRIDzQKS+k3MM2u8z6P4sgiOWVnXYnso0cHx/2AQ7Z1ClPB//HzbpHkd+mhaFaYCOH Uw3NNwp14TKfHLObCmglYYrR52GKZKV642DEXGHJS2KECxZRHcRScFZAaadHQ7g7pOmJ /Ujw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rtzN5zJv; 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 i9si13622955pgs.402.2019.05.06.07.37.29; Mon, 06 May 2019 07:37:30 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=rtzN5zJv; 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 S1727403AbfEFOh2 (ORCPT + 30 others); Mon, 6 May 2019 10:37:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:58112 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726308AbfEFOh0 (ORCPT ); Mon, 6 May 2019 10:37:26 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A7A44206A3; Mon, 6 May 2019 14:37:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557153445; bh=pajcmLcPQKgbIqeJurlmK4vrFJz+RTfrxOKFhXUH0RQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rtzN5zJv6EdTimq9kBh5073QC3N9QREKBR5Ht8pJiWu86NqKsE20cVyzSZM2rWARY gYILsdMmPkdbjIy8/T/OKt/6fJV5iHPVR1uaRAYJb967q5vxockc9/WIikgOPh+Bzb qsmTS99mcScYabVALtor4aseh+xpVWob65GeV0pw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Garry , "Martin K. Petersen" Subject: [PATCH 5.0 092/122] scsi: hisi_sas: Fix to only call scsi_get_prot_op() for non-NULL scsi_cmnd Date: Mon, 6 May 2019 16:32:30 +0200 Message-Id: <20190506143102.943296271@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190506143054.670334917@linuxfoundation.org> References: <20190506143054.670334917@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: John Garry commit e1ba0b0b44512c5a209526c09ea3eb7d256b6951 upstream. 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 Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -1033,8 +1033,8 @@ static void prep_ssp_v3_hw(struct hisi_h 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; @@ -1049,6 +1049,7 @@ static void prep_ssp_v3_hw(struct hisi_h 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: