Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2514593imm; Mon, 24 Sep 2018 05:45:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaYXJIOJYVYo5oBPZFb5OMX/REjrHydSiM7bycnkj/xi5V+/7IrBh9wRSGpKogAbIja2MRU X-Received: by 2002:a62:12c9:: with SMTP id 70-v6mr8640896pfs.140.1537793144746; Mon, 24 Sep 2018 05:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537793144; cv=none; d=google.com; s=arc-20160816; b=ZVYzkcg39MCmO8wkmg0jirsMsY3FfPWtceWxgel0XOrtzZ6CRMFArVDMwuyvye1RvK HoFB3twhCOf+8NtpeXRwssNI0Uk5jCoBa6Me6ilNrgkuPkvHuV8U2nRlcWkcBMJBo0vZ O2myLwn2dTzUaP68pbuVPnx8Ddw+jxgGVCHjyuXS4Kr3kwbyphSN8NoKdiP0HeZAriPV cGMW+U1yuzVCwLOtrGb9iL85R/l5BkRyJBWkVFxZX/AaBlmk8/h1U6TqAkriGpVZhsZW STrQiBeC68vy9n9kAGt3tTr2CjiC+MCFydd9ESmOAea1JFOj7UyRtCSjztFbvTzyxPdD UsqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=UEKkodTUczqRc23Wu9DXSpa5p7s2dyo+nsMvt4uIejo=; b=nGneBpbb0/rfwBjLc6OGXZoDAQGIVx8qgTnVdKkESWXs5pxdtYo0Oh7AoGZdiU0rp6 QhGf9cCtkS6w9wN3MYOaBp5M8Xgr5eQWExmKM8FV0AwELfHaKsVDclfSIhNA98Bv7z9s NrMt705Fnxe1zwvLCrPyd2jbYJifJdRizSt2Qi8UJK6nctPY83ITzaLmAJLuDjMtiYKD 2OqktKSAQsEIX+VDZnsWqdsEJk+olXYXrscEMv+l2JO0t2eN9BBzHa01XcaC+bMpxHy/ hkNoJjMAXKvRBq3rg6+rcocUWNx8xyi0dI8LkWK3PkL+Dx+aJ7C4Bu19nkDoBNOnQemm HAHA== 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 123-v6si35548078pfd.201.2018.09.24.05.45.29; Mon, 24 Sep 2018 05:45:44 -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 S2389141AbeIXSqX (ORCPT + 99 others); Mon, 24 Sep 2018 14:46:23 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59596 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732506AbeIXSqW (ORCPT ); Mon, 24 Sep 2018 14:46:22 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 17A9E1099; Mon, 24 Sep 2018 12:44:22 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dick Kennedy , James Smart , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.18 216/235] scsi: lpfc: Fix panic if driver unloaded when port is offline Date: Mon, 24 Sep 2018 13:53:22 +0200 Message-Id: <20180924113125.143659988@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: James Smart [ Upstream commit d580c6137476ab307a66e278cf7dbc666230f714 ] System crashes when the lpfc module is unloaded after making the port offline The nvme queue pointers were freed during port offline, but were later accessed in pci remove path. Validate the pointers in pci remove path before accessing them. Signed-off-by: Dick Kennedy Signed-off-by: James Smart Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/lpfc/lpfc_nvme.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/scsi/lpfc/lpfc_nvme.c +++ b/drivers/scsi/lpfc/lpfc_nvme.c @@ -2976,7 +2976,7 @@ lpfc_nvme_wait_for_io_drain(struct lpfc_ struct lpfc_sli_ring *pring; u32 i, wait_cnt = 0; - if (phba->sli_rev < LPFC_SLI_REV4) + if (phba->sli_rev < LPFC_SLI_REV4 || !phba->sli4_hba.nvme_wq) return; /* Cycle through all NVME rings and make sure all outstanding @@ -2985,6 +2985,9 @@ lpfc_nvme_wait_for_io_drain(struct lpfc_ for (i = 0; i < phba->cfg_nvme_io_channel; i++) { pring = phba->sli4_hba.nvme_wq[i]->pring; + if (!pring) + continue; + /* Retrieve everything on the txcmplq */ while (!list_empty(&pring->txcmplq)) { msleep(LPFC_XRI_EXCH_BUSY_WAIT_T1);