Received: by 10.213.65.68 with SMTP id h4csp431118imn; Tue, 13 Mar 2018 08:50:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELt3IarWF97wq8T7HAJQABPGVyWv1zI6bzNYGW5/khzKSpxxEOlLJoXp7+xoD3Ic4QLMYrwr X-Received: by 2002:a17:902:d24:: with SMTP id 33-v6mr1034144plu.8.1520956257748; Tue, 13 Mar 2018 08:50:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520956257; cv=none; d=google.com; s=arc-20160816; b=m5aaZn6l6zHAvLAt3N0Sr1a9YlW/OHRNgtWAnO8RUtSK1xLEcwq5t+oKUYKkQykYSt WtnYzrjEwadzVHF8TYQGzvajgCYdDTxas7ythvp3Q4UpSSqBHlMqctYYQawsSd/5TItA BtKvwxzRMPwn+6oO+a48vNbIE/z6egK03mgpWNQcFJjkqYeYG1bmJu91EM8l7NqIRjg5 NsB63mUzaiou+84LahRaYa3O082SS7QJw/xdfIS7w/iwhyVfR6R7D7MnbxPVnBRWLljp q9AWZPKGXXm7pJLow94jOdYW/UqUWOUmhhAlhiIiavzA9NCkN2RmfE+a8Dg2LYd5ko2U XyzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=eMklzGWc8EQ2+DUxFGI5fIhOe6MKMYy0o5B0Em6drTY=; b=Voeh1rI7yWKm2uborb9Q6chTZxYWdSrsMX+HCD46sijKeXcz6pHQzhvHO5M/fbwv8L mCLyx4kzNkAYUCmUsw5L6A/ZcduhHgdc8RYwvr0OaWFsIbltX9Rqp0ngzyXkUAbEsE+E Qojl+/bfI7/wssYBG0OatBaF8Pq/7BY2DU4lh6EvlvtyVKJTfX0GiSM4Oh4KxJz4LKlN Mra4zuYsNkehddrJtBmAubOeEe3ERw0IPJpJ5uc8uVwx0Do96T+YdnKaBw4x6G9pt0Sq BHR3B+ZoBoEizwFzN0JaY54jM24RnG4HggLTfCsNlqsKJ5fFNNH1uKbjYSZh02Ddg55t 8QhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z15si281901pge.522.2018.03.13.08.50.43; Tue, 13 Mar 2018 08:50:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934913AbeCMPke (ORCPT + 99 others); Tue, 13 Mar 2018 11:40:34 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35744 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934555AbeCMPkb (ORCPT ); Tue, 13 Mar 2018 11:40:31 -0400 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 8A56EFBC; Tue, 13 Mar 2018 15:40:30 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Himanshu Madhani , "Martin K. Petersen" Subject: [PATCH 4.14 111/140] scsi: qla2xxx: Fix NULL pointer crash due to probe failure Date: Tue, 13 Mar 2018 16:25:14 +0100 Message-Id: <20180313152505.614917029@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152458.201155692@linuxfoundation.org> References: <20180313152458.201155692@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: himanshu.madhani@cavium.com commit d64d6c5671db5e693a0caaee79f2571b098749c9 upstream. 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 Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/qla2xxx/qla_os.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3003,9 +3003,6 @@ qla2x00_probe_one(struct pci_dev *pdev, 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; } @@ -3066,7 +3063,7 @@ qla2x00_probe_one(struct pci_dev *pdev, /* 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)) { @@ -3375,6 +3372,9 @@ probe_failed: 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: