From patchwork Tue Jan 16 04:46:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10165955 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EA292601E7 for ; Tue, 16 Jan 2018 04:47:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D506427FAE for ; Tue, 16 Jan 2018 04:47:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9D5427FB3; Tue, 16 Jan 2018 04:47:04 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 05B2C27FAE for ; Tue, 16 Jan 2018 04:47:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751295AbeAPErD (ORCPT ); Mon, 15 Jan 2018 23:47:03 -0500 Received: from mail-cys01nam02on0075.outbound.protection.outlook.com ([104.47.37.75]:7968 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751284AbeAPErA (ORCPT ); Mon, 15 Jan 2018 23:47:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=y0fD7tHfgRaAYqOdJHN4yLOx0evaOW50C6m7RTzXr3c=; b=We94lD7X5fZVM8DM13yYpRANRkam1KEZb58WSsx5A018rkB64vMf0LD1kVckk9g/D5xSMsw8jOYdOU2SRVwgzMTzlLnWCip6WGIa93RC8QmluukAPQxG6fDx/u+WHdlg4Z5nYiVWaV1upqBGMUyCPXqWYeoa7IJkT/8jO6pYGBk= Received: from SN4PR0701CA0013.namprd07.prod.outlook.com (10.161.192.151) by BLUPR0701MB1937.namprd07.prod.outlook.com (10.163.121.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.407.7; Tue, 16 Jan 2018 04:46:58 +0000 Received: from BN1BFFO11FD034.protection.gbl (2a01:111:f400:7c10::1:143) by SN4PR0701CA0013.outlook.office365.com (2603:10b6:803:28::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.407.7 via Frontend Transport; Tue, 16 Jan 2018 04:46:58 +0000 Authentication-Results: spf=fail (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=cavium.com; Received-SPF: Fail (protection.outlook.com: domain of cavium.com does not designate 50.232.66.26 as permitted sender) receiver=protection.outlook.com; client-ip=50.232.66.26; helo=CAEXCH02.caveonetworks.com; Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BN1BFFO11FD034.mail.protection.outlook.com (10.58.144.97) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.345.12 via Frontend Transport; Tue, 16 Jan 2018 04:46:57 +0000 Received: from dut1171.mv.qlogic.com (172.29.51.171) by CAEXCH02.caveonetworks.com (10.17.4.29) with Microsoft SMTP Server id 14.2.347.0; Mon, 15 Jan 2018 20:46:53 -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 w0G4ksEx020735; Mon, 15 Jan 2018 20:46:54 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w0G4ksPp020734; Mon, 15 Jan 2018 20:46:54 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH 1/8] qla2xxx: Fix NULL pointer crash due to probe failure Date: Mon, 15 Jan 2018 20:46:46 -0800 Message-ID: <20180116044653.20696-2-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180116044653.20696-1-himanshu.madhani@cavium.com> References: <20180116044653.20696-1-himanshu.madhani@cavium.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:50.232.66.26; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(376002)(346002)(39860400002)(396003)(39380400002)(2980300002)(1110001)(1109001)(339900001)(199004)(189003)(48376002)(50466002)(16586007)(305945005)(47776003)(87636003)(26005)(316002)(4326008)(85426001)(42186006)(86362001)(50226002)(8936002)(8676002)(81156014)(81166006)(105606002)(106466001)(59450400001)(76176011)(1076002)(110136005)(54906003)(2906002)(51416003)(356003)(6666003)(5660300001)(478600001)(72206003)(2950100002)(80596001)(69596002)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1937; H:CAEXCH02.caveonetworks.com; FPR:; SPF:Fail; PTR:50-232-66-26-static.hfc.comcastbusiness.net; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD034; 1:fNlvH58QLiF3XMGNaRKphMN261CDn9K5ILRHyms65n4G1NsKtkm2XcFixFwseVQDJjWVMoUvB8FxuVqTepcHfXL5zI9wvqtPRC/JitFJQatikJWgNB3OE4R8EJe1Msho X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: aff0813b-1ead-4062-9dd7-08d55c9c2cef X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534125)(4602075)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060); SRVR:BLUPR0701MB1937; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1937; 3:scdLUTXhBGnvtFPPDKF2rJP8NHPyeaiLDEy6tfC13L4/9O34T3UhFsppGt4SGu+e1WKC2nQvBNKon9mfuicPukTR3m8MeBoFzldO9zvN7Xho+7hQMd2c9WQ3KvSchCj8T45wgNxwyzTOeDVS9jBaGeDKNWQ8K++eRNlQLxa9n2S/ZwvCBbV5Lkt+Dz0EzpQaowFkGRVhbepU9HICcodCO/yUl7asRxh9A71cQPtJh6ZA/PPv62GUXaY17H2lvXAdzqXnXIdE1Gfn7pLDz6lSSjf/kCrHOH7bv78eID2W+UI/WozmyTpo2WEK8fFq4IfPBEjRT327cE8bA1S/W5grkg==; 25:vB3EeV0ubdpIRpXQdAe12lgzH5dPpAz3wUCEOV4MnLILasjv1fAoIiABmdnKApYGDbKawopQSUWTU6E2U1InX+tXEjw1lYQ2+JmZe4EBSr4aVpjhX72pR/KGcVS/RnyGf1AgOyMgbTnvSoadQbfCnyEh66Q5VjtoUJQm/8UT7O77jHcgg5Rf9bgyyxslSLoftGd/qTr1E9uOrcQecOiLrCTSqawZdMXBIruu2MeuZspjQ4tKZP8QEEBmeC93CKvvhZtByOaC8fBaJ9ERK0EiYni5bonDOip4RTb3XTISllIC7DYupanxffWQ58yeZhu+gJ3otLS4u7YiVAhWU5Tw+w==; 31:WvR2BMwCj5OgFQge6mEzTlMaVYv2LPOyR+yoUP9jo22a2cs4dKxFrZoe78exu7bgKIAcReFwpxjYPJ2zNK/d/saYH0jh3Xxu7ZKpfdXVUGFpdeySYUvNPIDnTwl2LIkDW9DGIfKNSK+xfKkb8WWtMmDuqY4UEbiiQl5ISqbH3OJ8cBJIZuOJQEDcVY6wiMNBiriJQtdlk5fo+WTHekrXgZO+TDdnjk7vOLiigLaWEVM= X-MS-TrafficTypeDiagnostic: BLUPR0701MB1937: X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1937; 20:tNBZeXeN3PHa8FBymL6IHD70PbuZQbPKn1UK6zpPpz8iQFghqpReMwFCp3tiVMrX39M8EMGbqL7+XkckOBIjTvbpJCnvLdRHV/XjPdydrcrLVhoqvjpfABIm+IuYjwd4PGyCO5KD79flpvO4SWQFd9/SkkaOH1/fJuBMrcgTsjyPxCWgrmXxJFam7+8q/dDZ0v1wBUxtAM/dDZmQfmhdfUgQKDZCLo7XrSimq93q0lXcFL9FTwj9fHA5hXZ2RYxKyf7Ugj3JZHQVPR+zeAPjbd/fK1vAuPt9H/CIUv7CSAv10Y7D4sDb7u4heXorcYJ7kkMsPe2GzFylkpf4XgBbd+LQRDeTVDVxov4J1KC0pIqv5WO+Wb2g2A43F5iD7b+tYKa9suKpN7bzdeTJHpinAshsurpQdnzQV8/eB1Nl7Eio8C9ok0B3TBErFz1lAHPobL1JGmE7xZ0hqsKNj6BQLaYJ2Veo7rfUpWppg6k5JJVitAMSwhQCrGc83Vys7D8J; 4:whDS4TSX/6TxzPugWzKvAgWyZs0WCIuhW9MYBxUcqlB3OyXBQ9HeqvSlIjovKBZ6j5GEe6YMaH4yuW3pKtJVziULaSUqSifZzHT7o665c+2akhn5JlC+ra0WScHoHOdFZpfWOnErTPInbVWTWrT1+B+BM2hxh4kbe6PgOmbKsaA21E4k+nDuuQPeGjk8Zu+Qn5VuPTC8dS+1OEXEYpc9dVWLK37iRu0AiSn4GEsR3MXsjqqxj+jGRv2S/EoSz8ldecVLAqWFYVpiIF/tDRyD0LRhMeBmhUOzMjwJCQXmWVjb2Kp4gIPoX020/4Uag04H X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231023)(944501161)(3002001)(6041268)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:BLUPR0701MB1937; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:BLUPR0701MB1937; X-Forefront-PRVS: 0554B1F54F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0701MB1937; 23:I4FL3yqZDj6fEvSw5teqZys7w3j+mS2yksxEmtQ?= =?us-ascii?Q?CVVSbYa41FH0IqV/o/J4vo6lu6LS266/7Gv3n+57QOVeiZfZ+3EILJFaf2nt?= =?us-ascii?Q?4rBRXdgxypM7NQ5EYGDxS2ijXPp76fsmgkct5i1pJyhkFnJT2TKzWEPaHO6Q?= =?us-ascii?Q?LtYZS+GYuGDRK+AzRVBivpdoQIBNi9CrowKyY1UbwpJ3lAOjHM5Vf4AqHdTx?= =?us-ascii?Q?vkvptQOj6/BIPM72k9Gb6TkKNC14ymcXWbNs5zRmRUsuGu/rpf1NrDnTXdJD?= =?us-ascii?Q?zd8ANrDOoz9dxcYo/kAVViXBoj/jzwjllWdtyegFCbrymNKImjhj/DaPxBt7?= =?us-ascii?Q?4Tkc7do5Sv/CtscWoMLIhCY3AC+XntX06lw3oPMSKViRFYYg20d9yKI0ecly?= =?us-ascii?Q?ITAH5SQvXvxmQNwOaPseqRz3z8mJism40Bbrw8GRcxNHugzcX1aSZTcFryWb?= =?us-ascii?Q?LKj1JpVsiP85ygeleDpbODY3K1bBzfmLXRN86xtlFhCgqk5gfmoL53KaL61W?= =?us-ascii?Q?Zx0kdxxev9tDFognFgFQefMllQze0U5rrUCeeJGgc1nSd3UlQFjj+WnfPD7O?= =?us-ascii?Q?9qAxSrbM0Bbg3LQNHTZYl6LygFYZZqA1PB7BmcXZkZkMG+6nqXV+yrrJmjpe?= =?us-ascii?Q?9PsH7noSaPt53fay1UfMciMy76TOIvVvomm6ksGDa75n0+7U1FyyL/vQUuxQ?= =?us-ascii?Q?mXg87hi/dm72Fa6/ulLH9p1uFiWW1dC5ZK/l9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NNXLdrz2bLAoKe4s3clNprxkj/mjr17SV1aZ0WxEWykx+3JLZcHkqe/uNV8ovAhmWL6c3sQsfcxF2Nxh1V5cUzZBcX1RM6Pg=; 7:FxHvrhUiwHGHv8IKlrzUgKuSyoqgx/oSlKghr1K14kEQCwr+hX7zsH8eNPtMOINIb00FSSdBqQaRlVegmNvZuP6ljV30ls9S7RGW8jLtUd8oh7hxWm9ftngXnEA6X2sPywxiOwTcI4p4ShQ+2Cjs+HwjmhWXr4QrdW16FNXTMpXLIRC7IkS2hqCmWEsVKfh/8HfZjPD8CKlvVPsgKHEpqYrNurQs65q4AbgYOwtJ+lbo8JFePoY5vVzwEraMET6h SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2018 04:46:57.7759 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aff0813b-1ead-4062-9dd7-08d55c9c2cef X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=711e4ccf-2e9b-4bcf-a551-4094005b6194; Ip=[50.232.66.26]; Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1937 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 This patch fixes regression added by commit d74595278f4ab ("scsi: qla2xxx: Add multiple queue pair functionality."). When driver is not able to get reqeusted IRQs from the system, driver will attempt tp clean up memory before failing hardware probe. During this cleanup, driver assigns NULL value to the pointer which has not been allocated by driver yet. This results in a NULL pointer access. Log file will show following message and stack trace qla2xxx [0000:a3:00.1]-00c7:21: MSI-X: Failed to enable support, giving up -- 32/-1. qla2xxx [0000:a3:00.1]-0037:21: Falling back-to MSI mode --1. qla2xxx [0000:a3:00.1]-003a:21: Failed to reserve interrupt 821 already in use. BUG: unable to handle kernel NULL pointer dereference at (null) IP: [] qla2x00_probe_one+0x18b6/0x2730 [qla2xxx] PGD 0 Oops: 0002 [#1] SMP Fixes: d74595278f4ab ("scsi: qla2xxx: Add multiple queue pair functionality."). Cc: # 4.10 Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_os.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index b21878a70f6e..12ee6e02d146 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3035,9 +3035,6 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) base_vha = qla2x00_create_host(sht, ha); if (!base_vha) { ret = -ENOMEM; - qla2x00_mem_free(ha); - qla2x00_free_req_que(ha, req); - qla2x00_free_rsp_que(ha, rsp); goto probe_hw_failed; } @@ -3098,7 +3095,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) /* Set up the irqs */ ret = qla2x00_request_irqs(ha, rsp); if (ret) - goto probe_init_failed; + goto probe_hw_failed; /* Alloc arrays of request and response ring ptrs */ if (!qla2x00_alloc_queues(ha, req, rsp)) { @@ -3415,6 +3412,9 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) scsi_host_put(base_vha->host); probe_hw_failed: + qla2x00_mem_free(ha); + qla2x00_free_req_que(ha, req); + qla2x00_free_rsp_que(ha, rsp); qla2x00_clear_drv_active(ha); iospace_config_failed: