From patchwork Tue Oct 10 10:48:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jitendra Bhivare X-Patchwork-Id: 9995777 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 890E2603B5 for ; Tue, 10 Oct 2017 10:48:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8414A28500 for ; Tue, 10 Oct 2017 10:48:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7762D28503; Tue, 10 Oct 2017 10:48:48 +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, 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 1D73428500 for ; Tue, 10 Oct 2017 10:48:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755637AbdJJKsr (ORCPT ); Tue, 10 Oct 2017 06:48:47 -0400 Received: from mail-pf0-f172.google.com ([209.85.192.172]:43228 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755587AbdJJKsq (ORCPT ); Tue, 10 Oct 2017 06:48:46 -0400 Received: by mail-pf0-f172.google.com with SMTP id d2so13616651pfh.0 for ; Tue, 10 Oct 2017 03:48:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VyB1+BQZJUlJBI0kMD5bbqdsH/x+b3Ile5AtrGt5Ypw=; b=QdATb/UJnb++CpDkhNly13e58qTcPxynAfwOYD2R81nDyHsb26dFbJqV2ofy0Du1+x R7uqRHfy1g+Ej+C0rcjYW0GU+2skQytsINqI2W2L1MXWozSs97WkylYDQe2SJqq0x3mF 9iSQQcM4t9ovl26VX/aXEW0mTMYVji18KMaC8= 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=VyB1+BQZJUlJBI0kMD5bbqdsH/x+b3Ile5AtrGt5Ypw=; b=d3AbaHmpqzPxyIQ64CIuE3kPPfFy2A8bnVktG11Za3F9R4m3aMiohW+RLQnO2m0Knt mcCtBHUKYxc/6SyhVBdpbLpgqahXHwR0fD9iKjioHnjAotzfn9tRiY+pWpTOws9WCT0M CYTqXaXva7o5tNUWCJNRw9oMQ8v7r701ibgD49pi+1QPmVcRvUEAlqxu3SUpR2UnkO/6 iGe7+3+ldF/LGH/dUOn6b2Im4Mql/C4HqK70HlJny9wrpWkZ4z2N/GT10v1qtcp6intP YSM+EF23zbmEwTLeOVSmbs/oU+WbcZMFlUzDVrIlkbVbbOqKlJ6xuBrwft5aWTBLD7CA SUUA== X-Gm-Message-State: AMCzsaXwK3iR9lzjXuOUfSiaATz3ERVhXHDpwfQrJruahE9WdBSeyiOB PtCKvu95cv3ZcomkNVsOR+Ok7w== X-Google-Smtp-Source: AOwi7QAw/bTFGv4lAQCh8NxB6+Sp8BeT+9ghXcpb1GlBoYGLBCHfcaDxsH8c5Q/FxDXYjhV5xsVp5w== X-Received: by 10.84.224.131 with SMTP id s3mr11896977plj.409.1507632526249; Tue, 10 Oct 2017 03:48:46 -0700 (PDT) Received: from localhost.localdomain ([103.195.99.222]) by smtp.gmail.com with ESMTPSA id w13sm16131313pgq.13.2017.10.10.03.48.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Oct 2017 03:48:45 -0700 (PDT) From: Jitendra Bhivare To: cleech@redhat.com, lduncan@suse.com Cc: linux-scsi@vger.kernel.org, Jitendra Bhivare Subject: [PATCH 03/10] be2iscsi: Free msi_name and disable HW intr Date: Tue, 10 Oct 2017 16:18:13 +0530 Message-Id: <1507632500-26445-4-git-send-email-jitendra.bhivare@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507632500-26445-1-git-send-email-jitendra.bhivare@broadcom.com> References: <1507632500-26445-1-git-send-email-jitendra.bhivare@broadcom.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 In beiscsi_dev_probe, allocated msi_name does not get freed and enabled HW interrupts are not disabled in iscsi_host_add error case. Add beiscsi_free_irqs fn to handle the cleanup in probe and disable port. Signed-off-by: Jitendra Bhivare --- drivers/scsi/be2iscsi/be_main.c | 47 ++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 56ae0f4..8f7e394 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -790,6 +790,24 @@ static irqreturn_t be_isr(int irq, void *dev_id) return IRQ_HANDLED; } +static void beiscsi_free_irqs(struct beiscsi_hba *phba) +{ + struct hwi_context_memory *phwi_context; + int i; + + if (!phba->pcidev->msix_enabled) { + if (phba->pcidev->irq) + free_irq(phba->pcidev->irq, phba); + return; + } + + phwi_context = phba->phwi_ctrlr->phwi_ctxt; + for (i = 0; i <= phba->num_cpus; i++) { + free_irq(pci_irq_vector(phba->pcidev, i), + &phwi_context->be_eq[i]); + kfree(phba->msi_name[i]); + } +} static int beiscsi_init_irqs(struct beiscsi_hba *phba) { @@ -5396,15 +5414,7 @@ static void beiscsi_disable_port(struct beiscsi_hba *phba, int unload) phwi_ctrlr = phba->phwi_ctrlr; phwi_context = phwi_ctrlr->phwi_ctxt; hwi_disable_intr(phba); - if (phba->pcidev->msix_enabled) { - for (i = 0; i <= phba->num_cpus; i++) { - free_irq(pci_irq_vector(phba->pcidev, i), - &phwi_context->be_eq[i]); - kfree(phba->msi_name[i]); - } - } else - if (phba->pcidev->irq) - free_irq(phba->pcidev->irq, phba); + beiscsi_free_irqs(phba); pci_free_irq_vectors(phba->pcidev); for (i = 0; i < phba->num_cpus; i++) { @@ -5595,12 +5605,12 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev, if (ret) { beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, "BM_%d : be_ctrl_init failed\n"); - goto hba_free; + goto free_hba; } ret = beiscsi_init_sliport(phba); if (ret) - goto hba_free; + goto free_hba; spin_lock_init(&phba->io_sgl_lock); spin_lock_init(&phba->mgmt_sgl_lock); @@ -5680,13 +5690,13 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev, beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, "BM_%d : beiscsi_dev_probe-" "Failed to beiscsi_init_irqs\n"); - goto free_blkenbld; + goto disable_iopoll; } hwi_enable_intr(phba); ret = iscsi_host_add(phba->shost, &phba->pcidev->dev); if (ret) - goto free_blkenbld; + goto free_irqs; /* set online bit after port is operational */ set_bit(BEISCSI_HBA_ONLINE, &phba->state); @@ -5724,12 +5734,15 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev, "\n\n\n BM_%d : SUCCESS - DRIVER LOADED\n\n\n"); return 0; -free_blkenbld: - destroy_workqueue(phba->wq); +free_irqs: + hwi_disable_intr(phba); + beiscsi_free_irqs(phba); +disable_iopoll: for (i = 0; i < phba->num_cpus; i++) { pbe_eq = &phwi_context->be_eq[i]; irq_poll_disable(&pbe_eq->iopoll); } + destroy_workqueue(phba->wq); free_twq: hwi_cleanup_port(phba); beiscsi_cleanup_port(phba); @@ -5738,9 +5751,9 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev, pci_free_consistent(phba->pcidev, phba->ctrl.mbox_mem_alloced.size, phba->ctrl.mbox_mem_alloced.va, - phba->ctrl.mbox_mem_alloced.dma); + phba->ctrl.mbox_mem_alloced.dma); beiscsi_unmap_pci_function(phba); -hba_free: +free_hba: pci_disable_msix(phba->pcidev); pci_dev_put(phba->pcidev); iscsi_host_free(phba->shost);