From patchwork Fri Jan 25 07:23:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Madhani X-Patchwork-Id: 10780715 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5504F13BF for ; Fri, 25 Jan 2019 07:25:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A4F72EF10 for ; Fri, 25 Jan 2019 07:25:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E3B22EF78; Fri, 25 Jan 2019 07:25:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB5FD2EF10 for ; Fri, 25 Jan 2019 07:25:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728423AbfAYHZZ (ORCPT ); Fri, 25 Jan 2019 02:25:25 -0500 Received: from mail-eopbgr810075.outbound.protection.outlook.com ([40.107.81.75]:15232 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727034AbfAYHZZ (ORCPT ); Fri, 25 Jan 2019 02:25:25 -0500 Received: from DM5PR07CA0039.namprd07.prod.outlook.com (2603:10b6:3:16::25) by BN7PR07MB4371.namprd07.prod.outlook.com (2603:10b6:406:b5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.16; Fri, 25 Jan 2019 07:25:20 +0000 Received: from DM3NAM05FT037.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e51::203) by DM5PR07CA0039.outlook.office365.com (2603:10b6:3:16::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1558.17 via Frontend Transport; Fri, 25 Jan 2019 07:25:20 +0000 Authentication-Results: spf=fail (sender IP is 199.233.58.38) smtp.mailfrom=marvell.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=fail action=none header.from=marvell.com; Received-SPF: Fail (protection.outlook.com: domain of marvell.com does not designate 199.233.58.38 as permitted sender) receiver=protection.outlook.com; client-ip=199.233.58.38; helo=CAEXCH02.caveonetworks.com; Received: from CAEXCH02.caveonetworks.com (199.233.58.38) by DM3NAM05FT037.mail.protection.outlook.com (10.152.98.150) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.20.1580.2 via Frontend Transport; Fri, 25 Jan 2019 07:25:20 +0000 Received: from dut1171.mv.qlogic.com (10.112.88.18) by CAEXCH02.caveonetworks.com (10.67.98.110) with Microsoft SMTP Server (TLS) id 14.2.347.0; Thu, 24 Jan 2019 23:24:12 -0800 Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id x0P7OBcd003571; Thu, 24 Jan 2019 23:24:11 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id x0P7OBuR003570; Thu, 24 Jan 2019 23:24:11 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH 06/13] qla2xxx: fix fcport null pointer access. Date: Thu, 24 Jan 2019 23:23:44 -0800 Message-ID: <20190125072351.3504-7-hmadhani@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20190125072351.3504-1-hmadhani@marvell.com> References: <20190125072351.3504-1-hmadhani@marvell.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131928747208167547;(abac79dc-c90b-41ba-8033-08d666125e47);(abac79dc-c90b-41ba-8033-08d666125e47) X-Forefront-Antispam-Report: CIP:199.233.58.38;IPV:CAL;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(396003)(376002)(136003)(346002)(39860400002)(2980300002)(1109001)(1110001)(339900001)(189003)(199004)(110136005)(54906003)(50226002)(8936002)(498600001)(11346002)(2616005)(105606002)(106466001)(316002)(42186006)(53936002)(16586007)(81166006)(81156014)(8676002)(4326008)(2906002)(26005)(68736007)(86362001)(336012)(26826003)(476003)(126002)(87636003)(446003)(50466002)(48376002)(80596001)(97736004)(76176011)(69596002)(486006)(36906005)(14444005)(85426001)(51416003)(305945005)(47776003)(36756003)(1076003)(6666004)(356004);DIR:OUT;SFP:1101;SCL:1;SRVR:BN7PR07MB4371;H:CAEXCH02.caveonetworks.com;FPR:;SPF:Fail;LANG:en;PTR:InfoDomainNonexistent;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;DM3NAM05FT037;1:DAZrwOb8FKNyJ6gu8N4nq/MAvA1xPFQy/4d3AQA50xpPLt+80PgqU02gv3/Q46JGUojojYxHKh1OtQ3ukNKIJcK4oXvj+jbCt2AeCacs0q/50LRDGg1uByRhRgk+gDtdIbI5c8pQ/hGLU/0tatDXcg== X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dad80c88-c2d0-4aea-09d1-08d682964378 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(5600110)(711020)(4605077)(2017052603328);SRVR:BN7PR07MB4371; X-Microsoft-Exchange-Diagnostics: 1;BN7PR07MB4371;3:JDWX6HXpA530LvMpQwJhvm1ZyqBZqXT5o6T4QlYPxGiJAIiMVAypz5Z42RumJEUXq6VvAKTSp8FxHQU1f19L2s07d6spQoeKZMlnShPdH4CWfRjo6lxKvze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AHbYAtPwEH0n2YYbP86gsO27+65QjCAsVtr937tkG1BK9VBNyIkqPKcITaQnbDxYPgyHHZfQ8tCk/RxBlfYOIH1xAkNt99IitkbvUh99YF8+U8qvbkLtXqKSz8wyINU87+BUzmTvfK/583SwOPokq7wfY/gt/TcwvzfL0b3LIvO8sM5XtKwXFypF7WVBA6zpEgQDamn472Q6PChA+cWpRTrjQ+cZcfqszsbne90t4fYoPKuS+BdK7Q+buo/oMhLveFErR4fwxixEekmNhY2gJZq1cUm0EynWujDXfgA==;5:NpPY0H3rFj+xWOtMYplrFORDLE9UV+5ub1CBW2nunn1WXV2/fRfDvcUUcSvDaoygSyT4MHnYnaPRzvVbkW5hdZqUj5dhbLWrHVuUbQx2/i+h9HUPDF11ruXcdn5+nd9MGiF0xg9bIi3rH3tlIpCitrvMcvNqh5uqIH2ykBk7sXScPXdcH1w6q1yZvp5kX4X12GZ9OpAJfF9KBYbk4/kFaQ==;7:slKxEawG0DZ2H97WjwJv29CbyFMRi1YXPkhnM7As0dfn1aHuMEaXzxu+Y0m0HpX11i+R4ai03/dZA6GGywxeFKh95v5eZsO6ujkhg0dJSKbgGNoGAcjTZSynX6XaQC9dY4BGpcf2fwK867lhOX2lEw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2019 07:25:20.4774 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dad80c88-c2d0-4aea-09d1-08d682964378 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[199.233.58.38];Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR07MB4371 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Quinn Tran This patch allocates DMA memory to prevent NULL pointer access for ct_sns request while sending switch commands. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_init.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 58b4bfe01202..aa72e8316533 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -4755,6 +4755,16 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags) if (!fcport) return NULL; + fcport->ct_desc.ct_sns = dma_alloc_coherent(&vha->hw->pdev->dev, + sizeof(struct ct_sns_pkt), &fcport->ct_desc.ct_sns_dma, + flags); + if (!fcport->ct_desc.ct_sns) { + ql_log(ql_log_warn, vha, 0xd049, + "Failed to allocate ct_sns request.\n"); + kfree(fcport); + return NULL; + } + /* Setup fcport template structure. */ fcport->vha = vha; fcport->port_type = FCT_UNKNOWN; @@ -4763,13 +4773,11 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags) fcport->supported_classes = FC_COS_UNSPECIFIED; fcport->fp_speed = PORT_SPEED_UNKNOWN; - fcport->ct_desc.ct_sns = dma_alloc_coherent(&vha->hw->pdev->dev, - sizeof(struct ct_sns_pkt), &fcport->ct_desc.ct_sns_dma, - flags); fcport->disc_state = DSC_DELETED; fcport->fw_login_state = DSC_LS_PORT_UNAVAIL; fcport->deleted = QLA_SESS_DELETED; fcport->login_retry = vha->hw->login_retry_count; + fcport->chip_reset = vha->hw->base_qpair->chip_reset; fcport->logout_on_delete = 1; if (!fcport->ct_desc.ct_sns) { @@ -4778,6 +4786,7 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags) kfree(fcport); fcport = NULL; } + INIT_WORK(&fcport->del_work, qla24xx_delete_sess_fn); INIT_WORK(&fcport->reg_work, qla_register_fcport_fn); INIT_LIST_HEAD(&fcport->gnl_entry);