From patchwork Fri May 28 13:13:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandrakanth Patil X-Patchwork-Id: 12287027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,MIME_HEADER_CTYPE_ONLY, SPF_HELO_NONE,SPF_PASS,T_TVD_MIME_NO_HEADERS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF2F2C2B9F7 for ; Fri, 28 May 2021 13:13:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2FF2613E9 for ; Fri, 28 May 2021 13:13:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235853AbhE1NPc (ORCPT ); Fri, 28 May 2021 09:15:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234233AbhE1NPb (ORCPT ); Fri, 28 May 2021 09:15:31 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 046E4C061574 for ; Fri, 28 May 2021 06:13:57 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id v13so1600563ple.9 for ; Fri, 28 May 2021 06:13:56 -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=DiDIMiqc9B3JV75I5Hplx59o53D4BXmArTicNREC1zA=; b=DXNUvw0AdOQEOi5Nwy6EXDQMSsBljA8Tkgc1xWBFQXY+KdwncGS+Ij3arzZjGl6DSm lDLwNUlqde8j+p18VW8nRugOyB5BBHvshXuB4tSkH8ljahoit2I4CnH7K8DUiHFbzLsg KBOkB1mLR5Uzx854mCrdJsqbeB9SdQUG7zHpA= 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=DiDIMiqc9B3JV75I5Hplx59o53D4BXmArTicNREC1zA=; b=dD0bsbmWYkgBBKVimVfeeopWk8qo2BHrtzwK0yPjolN/YRwelk2WdkAX2PNHSAhGMO GfNjjhUm3E+8nvXUnWr8JZpV/qrGiW4mW93f9DNiy1gC9LF2GGgTMZFInFPc3AK8m7S4 Jwj01+qKbdeIdS41WAXPh1tq5tKxQLuvT5UxOYhEj5s3abTrNjrtS0gJs5HXVxj6oDGK WHxaSjFt3HlPhZe+4jkgXBvNZwF55adr/v/1ndcdvnn/fL9sbUwWjXZg8CrpvJH/N7bH eUKM7ab1rrGIr87RxUBKXNXQuCx40nD29ufPfzO71JL+gMQDODaFQQyBksgIsjwZSGUS ZUIw== X-Gm-Message-State: AOAM532fIcRou1wyw3QWojvYoOTXQYwpdnRUa7DVwM5s/N1nITBwCd/2 eVSrmVtx9WQ+BUPfqYZdXje556EQbExj2qxh87YJhXXebQRKX9VRGN2ZFUdmhkD01bTMdq22fSA hXqDdb3mQ04DH7oRzF6QGSpbIRFQB4gcVQkE+O6CHdCTmCneIeIzMuBh6EB7isGasfHePfGu0GF HMYCGrq6rG7FHQ5zo= X-Google-Smtp-Source: ABdhPJza7RqIj5H6rqDWWJ4iM9YhOVSQdm1iv6s2IZyJBp+LCNwB45innoD2LseObA7aumJwrMA9FQ== X-Received: by 2002:a17:902:aa02:b029:f0:cc19:faae with SMTP id be2-20020a170902aa02b02900f0cc19faaemr7918000plb.57.1622207635953; Fri, 28 May 2021 06:13:55 -0700 (PDT) Received: from dhcp-10-123-20-83.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id o2sm4238434pfu.80.2021.05.28.06.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 06:13:55 -0700 (PDT) From: Chandrakanth Patil To: linux-scsi@vger.kernel.org Cc: kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, Chandrakanth Patil Subject: [PATCH v3 2/5] megaraid_sas: Fix the resource leak in case of probe failure Date: Fri, 28 May 2021 18:43:04 +0530 Message-Id: <20210528131307.25683-3-chandrakanth.patil@broadcom.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20210528131307.25683-1-chandrakanth.patil@broadcom.com> References: <20210528131307.25683-1-chandrakanth.patil@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Driver doesn't cleanup all the allocated resources properly when scsi_add_host(),megasas_start_aen() function fails during the PCI device probe. This patch will cleanup all those resources. Signed-off-by: Chandrakanth Patil Signed-off-by: Sumit Saxena --- drivers/scsi/megaraid/megaraid_sas_base.c | 13 +++++++++++++ drivers/scsi/megaraid/megaraid_sas_fusion.c | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 8ed347eebf07..35b2137e0d1a 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -7545,11 +7545,16 @@ static int megasas_probe_one(struct pci_dev *pdev, return 0; fail_start_aen: + instance->unload = 1; + scsi_remove_host(instance->host); fail_io_attach: megasas_mgmt_info.count--; megasas_mgmt_info.max_index--; megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = NULL; + if (instance->requestorId && !instance->skip_heartbeat_timer_del) + del_timer_sync(&instance->sriov_heartbeat_timer); + instance->instancet->disable_intr(instance); megasas_destroy_irqs(instance); @@ -7557,8 +7562,16 @@ static int megasas_probe_one(struct pci_dev *pdev, megasas_release_fusion(instance); else megasas_release_mfi(instance); + if (instance->msix_vectors) pci_free_irq_vectors(instance->pdev); + instance->msix_vectors = 0; + + if (instance->fw_crash_state != UNAVAILABLE) + megasas_free_host_crash_buffer(instance); + + if (instance->adapter_type != MFI_SERIES) + megasas_fusion_stop_watchdog(instance); fail_init_mfi: scsi_host_put(host); fail_alloc_instance: diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index cd94a0c81f83..f79c19010c92 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -5272,6 +5272,7 @@ megasas_alloc_fusion_context(struct megasas_instance *instance) if (!fusion->log_to_span) { dev_err(&instance->pdev->dev, "Failed from %s %d\n", __func__, __LINE__); + kfree(instance->ctrl_context); return -ENOMEM; } }