From patchwork Sat Sep 30 00:34:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Smart X-Patchwork-Id: 9978881 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 23FE66037F for ; Sat, 30 Sep 2017 00:35:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17095298D1 for ; Sat, 30 Sep 2017 00:35:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BF0F298D5; Sat, 30 Sep 2017 00:35:15 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 ACD48298D1 for ; Sat, 30 Sep 2017 00:35:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752646AbdI3AfM (ORCPT ); Fri, 29 Sep 2017 20:35:12 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:35964 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752595AbdI3AfK (ORCPT ); Fri, 29 Sep 2017 20:35:10 -0400 Received: by mail-qk0-f195.google.com with SMTP id z14so776452qkg.3 for ; Fri, 29 Sep 2017 17:35:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bu3YKC/BZ4UUzgUuysPP4JoFuPlLNPyU5Vnksyd/JV8=; b=FYnukt0PtHBltL1hCrUPtSiEq2yR81V7vafD87DcCPEcWL0wfHcH7rEBMa9mv/wXsR Dzbg6jj0kNAuaS+LotcO6ugLtTlMWLvyx4wv6EUIL3C9C+PBnG8aV8el1osApz6QszG6 +3BG5hCgF/H8kLX+dYEbJNWVUodpvYv0swUxnnXN+uZUKH5BB/F1gyB3rnXMZ2vgOeJ5 snzjK0q5QRanblGd1x3mgTcNTEhBq0UxrS7bbz729wzrPrItp8Yc0SXXmEYLp88O/keB /MGVusL/lLjvbaIKn7Tm8PuTyusLipjMorJlaEPOe5HbPedxNCbM8+/PUJphjgaZdZKu pIeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bu3YKC/BZ4UUzgUuysPP4JoFuPlLNPyU5Vnksyd/JV8=; b=A30tnm9EWXf6H0VvA2YU6Fq4eXSKtsO7CJJuzJTbThOj93yhpef4f34hU1YB1csViQ jgYodJnqrUp2uWKu1ZOGCSZCRoLraLxrmLMiWg8Ecf0Lj3+b0X1O0W4b1aGqesWBSyps 4GmjeOED9Rbs8FwFrE18DsbwXKBYmYeV18rt/SqYWT5f014RHonm38kqYGWz9sOFtLq9 6kConjd9wpDvDHw1cosp4LcRhcx6YQZCcarVbkJ31CDi/skwmz61D9r3Mx9aRwr5OvE6 Kfugu8b/7jN+d1FKbCZ3cUGbFXgg/XgPf6TWU6D/XEa4E+eTd2p6g1KmE2FFgsS9a1dh 4I8Q== X-Gm-Message-State: AMCzsaWUNUNn4O4K+gwxZiMGYzLPe6DnbQg7gIdEJhjBJx8fwHHphaJJ kx5gpG71+Ujqbo4dcEBbMieslA== X-Google-Smtp-Source: AOwi7QAm6lJ23tnhnFoNxWuOzG9OoYyYREwnX9zZihC2A07quue6hZfg5waMSochjeFuyRP4jo+pJA== X-Received: by 10.55.87.133 with SMTP id l127mr5590372qkb.212.1506731709704; Fri, 29 Sep 2017 17:35:09 -0700 (PDT) Received: from pallmd1.broadcom.com ([192.19.255.250]) by smtp.gmail.com with ESMTPSA id u32sm3596918qte.25.2017.09.29.17.35.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Sep 2017 17:35:09 -0700 (PDT) From: James Smart To: linux-scsi@vger.kernel.org Cc: Dick Kennedy , James Smart Subject: [PATCH v2 15/21] lpfc: Fix crash in lpfc_nvme_fcp_io_submit during LIP Date: Fri, 29 Sep 2017 17:34:41 -0700 Message-Id: <20170930003447.10747-16-jsmart2021@gmail.com> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20170930003447.10747-1-jsmart2021@gmail.com> References: <20170930003447.10747-1-jsmart2021@gmail.com> 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: Dick Kennedy The driver is seeing a NULL pointer in lpfc_nvme_fcp_io_submit. This was ultimately due to a transport AER being sent on a terminated controller, thus some of the values were not set. In case we're in a system without a corrected transport and in case a race condition occurs where we enter the routine as the teardown is happening in a separate thread, validate the parameters before starting the io. Signed-off-by: Dick Kennedy Signed-off-by: James Smart Reviewed-by: Johannes Thumshirn --- drivers/scsi/lpfc/lpfc_nvme.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c index e6948945a2f2..02ba06f364c4 100644 --- a/drivers/scsi/lpfc/lpfc_nvme.c +++ b/drivers/scsi/lpfc/lpfc_nvme.c @@ -1235,6 +1235,16 @@ lpfc_nvme_fcp_io_submit(struct nvme_fc_local_port *pnvme_lport, vport = lport->vport; phba = vport->phba; + /* Validate pointers. */ + if (!pnvme_lport || !pnvme_rport || !freqpriv) { + lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR | LOG_NODE, + "6117 No Send:IO submit ptrs NULL, lport %p, " + "rport %p fcreq_priv %p\n", + pnvme_lport, pnvme_rport, freqpriv); + ret = -ENODEV; + goto out_fail; + } + #ifdef CONFIG_SCSI_LPFC_DEBUG_FS if (phba->ktime_on) start = ktime_get_ns();