Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2516036imm; Mon, 24 Sep 2018 05:47:07 -0700 (PDT) X-Google-Smtp-Source: ACcGV61OcikOwPnclWNXIj2r2ohaZtCkU1QnM3a1FtVNYTb6+zxE8gt5CjMw5h6Jq2QLGswPLFsr X-Received: by 2002:a63:1d47:: with SMTP id d7-v6mr9381491pgm.180.1537793227145; Mon, 24 Sep 2018 05:47:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537793227; cv=none; d=google.com; s=arc-20160816; b=SU8a+lzx9esGF32kxlnAiUEt+unUAU35IytbKjw00kjpiTd5TWA3L8IU6l1lON93zL yGXw+Mwj6k++0B86lMcnY9n2U9Z5aMQP/LQo2ETcRaCvf5JZSEkmcXY/GwuxEKIlGkRj 8jQ5HBwJgEl4c2mMrgncMaAWiX+gQhf6kZeTkxboCmh3w2IIL+T3H+F9ACXdeNJAQtCs e//IYuko9d++kHYDQE4DjeZSruqPZU3o2o9pb8Z2OVwhrfQ6WXME5VYfSnqzUelr0fle akwFjVhy59sTaS9qkePrq0z7DCPSlDFrLVwrhok/t8m5X7TBkeyJzf3xnseGllhYFOdu S9uA== 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=zTU3JI34W0cjcgohDA2bpDO4ZALxWsurqEAoYOgq9rA=; b=MVIwGCC++72IfYAR9GcRBW2O52bvXaf+/NJzImTfcYls0RFSLCxqk7a3JB8alXs5dY jRtxuxozLW+rZ/3pFexE1l4bV8CpU4oXeRRZEbKKjb09KdRWC8PeyzEqpzF/7Fg9kngp w11FLGtzb2q1rbgBxCBiOeUVCkNlx/JOrI6kUqjjKKPwRM0XLkp1J5peyJhYYxbtSNFo j5AIdbhzcuOP9a8QahTVtFsUcHN/j9sE5W1uKYzGjPQW8L0uXR7TCGJA+8Ms6NPfMpaX kK1igqKS41YKVp1JSazCC0ygWHjfzs+36TZ+zOCT+rqdLcOAHA89rAEfIW5XUwzW9zcv mQww== 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 m125-v6si12441122pgm.541.2018.09.24.05.46.51; Mon, 24 Sep 2018 05:47:07 -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 S2389414AbeIXSsJ (ORCPT + 99 others); Mon, 24 Sep 2018 14:48:09 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59886 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730401AbeIXSsJ (ORCPT ); Mon, 24 Sep 2018 14:48:09 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 373CF109A; Mon, 24 Sep 2018 12:46:09 +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 215/235] scsi: lpfc: Fix NVME Target crash in defer rcv logic Date: Mon, 24 Sep 2018 13:53:21 +0200 Message-Id: <20180924113125.096745368@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 6871e8144f935a1f08e7fc6269c894861ce494aa ] Kernel occasionally crashed with the following ops on NVME Target: BUG: unable to handle kernel NULL pointer dereference at 0000000000000058 IP: [] lpfc_nvmet_defer_rcv+0x50/0x70 [lpfc] Callback routine was called for deferred rcv when it should be treated as a normal rcv. Added code in callback routine to detect this condition and log a message, then bail. 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_nvmet.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) --- a/drivers/scsi/lpfc/lpfc_nvmet.c +++ b/drivers/scsi/lpfc/lpfc_nvmet.c @@ -402,6 +402,7 @@ lpfc_nvmet_ctxbuf_post(struct lpfc_hba * /* Process FCP command */ if (rc == 0) { + ctxp->rqb_buffer = NULL; atomic_inc(&tgtp->rcv_fcp_cmd_out); nvmebuf->hrq->rqbp->rqb_free_buffer(phba, nvmebuf); return; @@ -1116,8 +1117,17 @@ lpfc_nvmet_defer_rcv(struct nvmet_fc_tar lpfc_nvmeio_data(phba, "NVMET DEFERRCV: xri x%x sz %d CPU %02x\n", ctxp->oxid, ctxp->size, smp_processor_id()); + if (!nvmebuf) { + lpfc_printf_log(phba, KERN_INFO, LOG_NVME_IOERR, + "6425 Defer rcv: no buffer xri x%x: " + "flg %x ste %x\n", + ctxp->oxid, ctxp->flag, ctxp->state); + return; + } + tgtp = phba->targetport->private; - atomic_inc(&tgtp->rcv_fcp_cmd_defer); + if (tgtp) + atomic_inc(&tgtp->rcv_fcp_cmd_defer); /* Free the nvmebuf since a new buffer already replaced it */ nvmebuf->hrq->rqbp->rqb_free_buffer(phba, nvmebuf);