From cf6f6cf41f56ff4c996323ed4c3a913ed7e0d374 Mon Sep 17 00:00:00 2001
From: Himanshu Madhani <hmadhani@redhat.com>
Date: Thu, 21 Nov 2019 16:36:58 -0500
Subject: [PATCH 148/155] [scsi] scsi: qla2xxx: Fix a NULL pointer dereference
Message-id: <20191121163701.43688-24-hmadhani@redhat.com>
Patchwork-id: 287865
O-Subject: [RHLE 7.8 e-stor PATCH v3 23/26] scsi: qla2xxx: Fix a NULL pointer dereference
Bugzilla: 1731581
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
RH-Acked-by: Ewan Milne <emilne@redhat.com>
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
From: Bart Van Assche <bvanassche@acm.org>
Bugzilla 1731581
BUG: KASAN: null-ptr-deref in qla24xx_handle_plogi_done_event+0x134/0x9f0 [qla2xxx]
Read of size 4 at addr 00000000000000a0 by task swapper/2/0
CPU: 2 PID: 0 Comm: swapper/2 Not tainted 5.2.0-dbg+ #1
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
Call Trace:
<IRQ>
dump_stack+0x8a/0xd6
__kasan_report.cold+0x5/0x41
kasan_report+0x16/0x20
__asan_load4+0x7e/0x80
qla24xx_handle_plogi_done_event+0x134/0x9f0 [qla2xxx]
qla2x00_els_dcmd2_sp_done+0x15f/0x230 [qla2xxx]
qla24xx_els_ct_entry+0x3b3/0x610 [qla2xxx]
qla24xx_process_response_queue+0x514/0x10e0 [qla2xxx]
qla24xx_msix_rsp_q+0x80/0x100 [qla2xxx]
__handle_irq_event_percpu+0x72/0x450
handle_irq_event_percpu+0x74/0xf0
handle_irq_event+0x5e/0x8f
handle_edge_irq+0x13a/0x320
handle_irq+0x30/0x40
do_IRQ+0x91/0x190
common_interrupt+0xf/0xf
</IRQ>
RIP: 0010:default_idle+0x31/0x230
Fixes: 8777e4314d39 ("scsi: qla2xxx: Migrate NVME N2N handling into state machine") # v4.19.
Cc: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Himanshu Madhani <hmadhani@marvell.com>
Reviewed-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit d1436e456b840162eb4d162f99055d2adb79a566)
Signed-off-by: Himanshu Madhani <hmadhani@redhat.com>
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
drivers/scsi/qla2xxx/qla_iocb.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 05acf2f85895..918b18d53599 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -2868,7 +2868,8 @@ qla2x00_els_dcmd2_sp_done(void *ptr, int res)
case CS_COMPLETE:
memset(&ea, 0, sizeof(ea));
ea.fcport = fcport;
- ea.rc = res;
+ ea.data[0] = MBS_COMMAND_COMPLETE;
+ ea.sp = sp;
qla24xx_handle_plogi_done_event(vha, &ea);
break;
--
2.13.6