From patchwork Sat Sep 30 00:34:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Smart X-Patchwork-Id: 9978865 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 4E90F6037F for ; Sat, 30 Sep 2017 00:35:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 406C6298D1 for ; Sat, 30 Sep 2017 00:35:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34617298D5; Sat, 30 Sep 2017 00:35:02 +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 D0DA6298D1 for ; Sat, 30 Sep 2017 00:35:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752600AbdI3AfA (ORCPT ); Fri, 29 Sep 2017 20:35:00 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:47060 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752571AbdI3Ae6 (ORCPT ); Fri, 29 Sep 2017 20:34:58 -0400 Received: by mail-qt0-f194.google.com with SMTP id s18so1621133qta.3; Fri, 29 Sep 2017 17:34:57 -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=UCC6dBM8+5WsFlub8jHQ2+hHzvGAFiFvVsEFTKuNH4U=; b=n9cL/Q8uFDOVXIJD9Upi+uMUPsSzzW5QqTUqVrl5mVA0LE4Sz/vdnAQGj84SMEWWfd 9vatabR5Fe5dX3yGqHxR3drfjzs/k5xNmJ3vxaLGK4UEtzXkOalcEKlrqP0DNDaHad9y IEPt4aT1ruNEaqgw9NniPXqKruxXxhAmUgewbVeRqlwC1LgcR6cTFXPHX2McAUu1gUiP pFB9sLwT1LnxJbPu5mKjYus5H41jBYp9ESdpX/zhI5i7Y9xeYMN3p5GzeoGInj2XPoIi Hmsto6IEng7Yl5CRMFKvqru9tvNfc4ox/At8KYM8emLFFO7R30Mvayuozy/EegROORJz ZfqQ== 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=UCC6dBM8+5WsFlub8jHQ2+hHzvGAFiFvVsEFTKuNH4U=; b=aGZf+O2GY08iPICUMjQ90pFOn2rSX21oT3LVECMIiixnQMK6B+uSLHrhoFN4G5wICf cfMJ8wTWWLadSDSr4HzOOu7vRFosXliqqITxLMd4r2/IeKYZBY85UM8UOQaqaK/Doaus XVu95N4sOiiRQLkbP6L7SfRCChFbXXh+NM5GBsJXHCVCTxtdMltHjMOKPcRs77Q93rxa 6/Bm/mX2vsUQ9PG7ZXonOq7x8zfE5x/yIjYqeY03Uu9d3DEeIDFLr6jb/KD5bWLlN+Hu guvOfH+ZazU47lcTQai1OXf2HFgOsLXLkq4rswrdX0kQA66GKClk7CyC6M2tdou8SB5e 0pWw== X-Gm-Message-State: AMCzsaVGC5bIBPz4lzbWaNv7OG5dpZOga7PiQYEpWNzBgMZtbpW5tTT7 0EXhtjdgtlccZw7W/Z4w/OjVYw== X-Google-Smtp-Source: AOwi7QBqtkmjXNGu/MWKLxvwVIjo5dBehPEZI5A3cA+y2x6T/aparqXe16lBMjw9yjLSlfME86rFnw== X-Received: by 10.200.12.69 with SMTP id l5mr9111522qti.268.1506731697181; Fri, 29 Sep 2017 17:34:57 -0700 (PDT) Received: from pallmd1.broadcom.com ([192.19.255.250]) by smtp.gmail.com with ESMTPSA id u32sm3596918qte.25.2017.09.29.17.34.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Sep 2017 17:34:56 -0700 (PDT) From: James Smart To: linux-scsi@vger.kernel.org Cc: Dick Kennedy , stable@vger.kernel.org, James Smart Subject: [PATCH v2 02/21] lpfc: fix pci hot plug crash in list_add call Date: Fri, 29 Sep 2017 17:34:28 -0700 Message-Id: <20170930003447.10747-3-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 During pci hot plug, the kernel crashes in a list_add_call The lookup by tag function will return null if the IOCB is out of range or does not have the on txcmplq flag set. Fix: Check for null return from lookup by tag. Cc: # 4.12+ Signed-off-by: Dick Kennedy Signed-off-by: James Smart Reviewed-by: Johannes Thumshirn --- v2: original v1 hot plug patch split into 2 patches drivers/scsi/lpfc/lpfc_sli.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 8b119f87b51d..b8513c1adcef 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -12507,19 +12507,21 @@ lpfc_sli4_els_wcqe_to_rspiocbq(struct lpfc_hba *phba, /* Look up the ELS command IOCB and create pseudo response IOCB */ cmdiocbq = lpfc_sli_iocbq_lookup_by_tag(phba, pring, bf_get(lpfc_wcqe_c_request_tag, wcqe)); - /* Put the iocb back on the txcmplq */ - lpfc_sli_ringtxcmpl_put(phba, pring, cmdiocbq); - spin_unlock_irqrestore(&pring->ring_lock, iflags); - if (unlikely(!cmdiocbq)) { + spin_unlock_irqrestore(&pring->ring_lock, iflags); lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, "0386 ELS complete with no corresponding " - "cmdiocb: iotag (%d)\n", - bf_get(lpfc_wcqe_c_request_tag, wcqe)); + "cmdiocb: 0x%x 0x%x 0x%x 0x%x\n", + wcqe->word0, wcqe->total_data_placed, + wcqe->parameter, wcqe->word3); lpfc_sli_release_iocbq(phba, irspiocbq); return NULL; } + /* Put the iocb back on the txcmplq */ + lpfc_sli_ringtxcmpl_put(phba, pring, cmdiocbq); + spin_unlock_irqrestore(&pring->ring_lock, iflags); + /* Fake the irspiocbq and copy necessary response information */ lpfc_sli4_iocb_param_transfer(phba, irspiocbq, cmdiocbq, wcqe); @@ -17137,7 +17139,8 @@ lpfc_sli4_handle_mds_loopback(struct lpfc_vport *vport, if (pcmd && pcmd->virt) dma_pool_free(phba->lpfc_drb_pool, pcmd->virt, pcmd->phys); kfree(pcmd); - lpfc_sli_release_iocbq(phba, iocbq); + if (iocbq) + lpfc_sli_release_iocbq(phba, iocbq); lpfc_in_buf_free(phba, &dmabuf->dbuf); }