From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-co1nam03on0136.outbound.protection.outlook.com ([104.47.40.136]:48409 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933357AbeCSPsU (ORCPT ); Mon, 19 Mar 2018 11:48:20 -0400 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Quinn Tran , Himanshu Madhani , "Martin K . Petersen" , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 044/124] scsi: qla2xxx: Fix NULL pointer access for fcport structure Date: Mon, 19 Mar 2018 15:47:45 +0000 Message-ID: <20180319154645.11350-44-alexander.levin@microsoft.com> References: <20180319154645.11350-1-alexander.levin@microsoft.com> In-Reply-To: <20180319154645.11350-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Quinn Tran [ Upstream commit 5c25d451163cab9be80744cbc5448d6b95ab8d1a ] when processing iocb in a timeout case, driver was trying to log messages without verifying if the fcport structure could have valid data. This results in a NULL pointer access. Fixes: 726b85487067("qla2xxx: Add framework for async fabric discovery") Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/qla2xxx/qla_init.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_ini= t.c index 6082389f25c3..7b44a2c68a45 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -102,11 +102,16 @@ qla2x00_async_iocb_timeout(void *data) struct srb_iocb *lio =3D &sp->u.iocb_cmd; struct event_arg ea; =20 - ql_dbg(ql_dbg_disc, fcport->vha, 0x2071, - "Async-%s timeout - hdl=3D%x portid=3D%06x %8phC.\n", - sp->name, sp->handle, fcport->d_id.b24, fcport->port_name); + if (fcport) { + ql_dbg(ql_dbg_disc, fcport->vha, 0x2071, + "Async-%s timeout - hdl=3D%x portid=3D%06x %8phC.\n", + sp->name, sp->handle, fcport->d_id.b24, fcport->port_name); =20 - fcport->flags &=3D ~FCF_ASYNC_SENT; + fcport->flags &=3D ~FCF_ASYNC_SENT; + } else { + pr_info("Async-%s timeout - hdl=3D%x.\n", + sp->name, sp->handle); + } =20 switch (sp->type) { case SRB_LOGIN_CMD: --=20 2.14.1