Blame SOURCES/0008-scsi-scsi-qla2xxx-fix-fcport-null-pointer-access.patch

3c6e85
From 5a596997bebb5296b412c648e1c99083ab6943cc Mon Sep 17 00:00:00 2001
3c6e85
From: Himanshu Madhani <hmadhani@redhat.com>
3c6e85
Date: Thu, 1 Aug 2019 15:54:28 -0400
3c6e85
Subject: [PATCH 008/124] [scsi] scsi: qla2xxx: fix fcport null pointer access
3c6e85
3c6e85
Message-id: <20190801155618.12650-9-hmadhani@redhat.com>
3c6e85
Patchwork-id: 267785
3c6e85
O-Subject: [RHEL 7.8 e-stor PATCH 008/118] scsi: qla2xxx: fix fcport null pointer access.
3c6e85
Bugzilla: 1729270
3c6e85
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
3c6e85
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
3c6e85
3c6e85
From: Quinn Tran <quinn.tran@cavium.com>
3c6e85
3c6e85
Bugzilla 1729270
3c6e85
3c6e85
This patch allocates DMA memory to prevent NULL pointer access for ct_sns
3c6e85
request while sending switch commands.
3c6e85
3c6e85
Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
3c6e85
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
3c6e85
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3c6e85
(cherry picked from commit 9ecd6564d1547d64fec464fdae75c82794c94c51)
3c6e85
Signed-off-by: Himanshu Madhani <hmadhani@redhat.com>
3c6e85
Signed-off-by: Jan Stancek <jstancek@redhat.com>
3c6e85
---
3c6e85
 drivers/scsi/qla2xxx/qla_init.c | 15 ++++++++++++---
3c6e85
 1 file changed, 12 insertions(+), 3 deletions(-)
3c6e85
3c6e85
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
3c6e85
index a047c0c0500f..6f03fb7c2f94 100644
3c6e85
--- a/drivers/scsi/qla2xxx/qla_init.c
3c6e85
+++ b/drivers/scsi/qla2xxx/qla_init.c
3c6e85
@@ -4683,6 +4683,16 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags)
3c6e85
 	if (!fcport)
3c6e85
 		return NULL;
3c6e85
 
3c6e85
+	fcport->ct_desc.ct_sns = dma_alloc_coherent(&vha->hw->pdev->dev,
3c6e85
+		sizeof(struct ct_sns_pkt), &fcport->ct_desc.ct_sns_dma,
3c6e85
+		flags);
3c6e85
+	if (!fcport->ct_desc.ct_sns) {
3c6e85
+		ql_log(ql_log_warn, vha, 0xd049,
3c6e85
+		    "Failed to allocate ct_sns request.\n");
3c6e85
+		kfree(fcport);
3c6e85
+		return NULL;
3c6e85
+	}
3c6e85
+
3c6e85
 	/* Setup fcport template structure. */
3c6e85
 	fcport->vha = vha;
3c6e85
 	fcport->port_type = FCT_UNKNOWN;
3c6e85
@@ -4691,13 +4701,11 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags)
3c6e85
 	fcport->supported_classes = FC_COS_UNSPECIFIED;
3c6e85
 	fcport->fp_speed = PORT_SPEED_UNKNOWN;
3c6e85
 
3c6e85
-	fcport->ct_desc.ct_sns = dma_alloc_coherent(&vha->hw->pdev->dev,
3c6e85
-		sizeof(struct ct_sns_pkt), &fcport->ct_desc.ct_sns_dma,
3c6e85
-		flags);
3c6e85
 	fcport->disc_state = DSC_DELETED;
3c6e85
 	fcport->fw_login_state = DSC_LS_PORT_UNAVAIL;
3c6e85
 	fcport->deleted = QLA_SESS_DELETED;
3c6e85
 	fcport->login_retry = vha->hw->login_retry_count;
3c6e85
+	fcport->chip_reset = vha->hw->base_qpair->chip_reset;
3c6e85
 	fcport->logout_on_delete = 1;
3c6e85
 
3c6e85
 	if (!fcport->ct_desc.ct_sns) {
3c6e85
@@ -4706,6 +4714,7 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags)
3c6e85
 		kfree(fcport);
3c6e85
 		fcport = NULL;
3c6e85
 	}
3c6e85
+
3c6e85
 	INIT_WORK(&fcport->del_work, qla24xx_delete_sess_fn);
3c6e85
 	INIT_WORK(&fcport->reg_work, qla_register_fcport_fn);
3c6e85
 	INIT_LIST_HEAD(&fcport->gnl_entry);
3c6e85
-- 
3c6e85
2.13.6
3c6e85