Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2570072yba; Mon, 6 May 2019 08:08:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8nIcjga/42gBDSZuqbSU+UX9/3g6678Dp2ndzDLEwp0JgRYcEwGHE2ztmBc88Ta94SSWG X-Received: by 2002:aa7:9a99:: with SMTP id w25mr28032197pfi.249.1557155337789; Mon, 06 May 2019 08:08:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557155337; cv=none; d=google.com; s=arc-20160816; b=Ah0gSw/nwl03cJ4yS5LRhRMJfyR4efdU5nXA1xwgbyCzF9XVb/Sn6sSjmMzhPlW/OG dNws/P63k/ZU7cbBfv1r+tsnQumR22RnpHaA6F8ozw9AlNmg9Cy2IeZ/lYQ4NIWdPUXK G5IkY7DhyVeEC07pYhMrFwZyKa9M0H/hncacBCQJiLJ/H4GiCa1w7c3z7TulxhhiVCF/ +jVwQdGxO7xNwAJiCAKxLsKlvRmeYniC3GyGRcTLnMOGxgT08KoCSi/Iy3hr9IXqU8eg fhnlUddhB1Z/mP/yq8fDRajLTjsgFyOaT6TpFQRMbVEbSDtSxiBoWswDNyZ7EEfLWYJm DTpA== 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 cn16si16055473plb.174.2019.05.06.08.08.41; Mon, 06 May 2019 08:08:57 -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 S1727399AbfEFOh2 (ORCPT + 99 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: