From patchwork Fri May 21 10:25:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandrakanth Patil X-Patchwork-Id: 446140 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, URIBL_BLOCKED, 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 644B9C433ED for ; Fri, 21 May 2021 10:27:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 483BD613BD for ; Fri, 21 May 2021 10:27:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229724AbhEUK2U (ORCPT ); Fri, 21 May 2021 06:28:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232170AbhEUK15 (ORCPT ); Fri, 21 May 2021 06:27:57 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBD4FC061574 for ; Fri, 21 May 2021 03:26:32 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id d78so13714097pfd.10 for ; Fri, 21 May 2021 03:26:32 -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=AGsp065a2GVEmhI2AMfgVrrsFc3IjmZCaM+JG3LRsRQ=; b=Fmlv33lSYs/LIeIAMy8j08ipVhkHEWGMbpIX6ry1q1Du/hDy+a5skChgIO7NHsu1dS /I4Lo7albvQMoD3okQCmGLiF1Bd8dduHtyeo38vyUmPge74DYZGYHKA8QdMpR3SYju5G TxClAVzkQWph6q81nIaOqv421MOKO/HNMOyoQ= 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=AGsp065a2GVEmhI2AMfgVrrsFc3IjmZCaM+JG3LRsRQ=; b=plTXowiOccum7xUYhKDz//1bsvjmp9M8WRPYfMmz6jmmDiyt1Uxyoras3R9hcPVRa5 njNBAePkYabJsmKZFjPGdQn7fEJe+4TRfOvNOa+ehZbpINtVk85NahUTVMnEUjgnTsXC yXXNSXfIeMkYCO7JBv90rooVoO7kUwhBmZ0aftm8ERmLTEHlTHXLZKwodfn2EZV/vvYX NM+0VxLaoZfdzvFwArwqlPQWwAA9Fp4hM//jfczbFYuJ4faCga9gKTiK44m3fYPBKpj+ 8EzhfLhhowpLjspcWsAwXwStTooUbFeqhVmEO3secvKgiL4YuwEienknVYCPEzABh3Xo TEWg== X-Gm-Message-State: AOAM530G77X+n26kltRHtF9u8Q6NYq4DbN0E6l8Onn3X9gqnXDGHZZf9 rN7Y4E37Fd/wxP/kTi8yQYbzzEKaGgmK+tRA+XJjR1BXGGBwjyKUZlUezJB9MZo/gvD4mBDUzOQ f7ilddVHGMYYeYpRiXNOZQCfuaK3XjWiiT52isKe+/vdfjvYGEQ+tlPVxI9ULzUessbebyBHeQf BmS5YqAuAyGuPa2RM= X-Google-Smtp-Source: ABdhPJxc2aXTbJjTyev661SSTG72GzoIE3FVTzrNlfAYEi5XEac05qOOKaJVEZg05zSwZYA4N26mCA== X-Received: by 2002:aa7:8d5a:0:b029:227:7b07:7d8b with SMTP id s26-20020aa78d5a0000b02902277b077d8bmr9385036pfe.26.1621592791882; Fri, 21 May 2021 03:26:31 -0700 (PDT) Received: from dhcp-10-123-20-83.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id j3sm4197858pfe.98.2021.05.21.03.26.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 03:26:31 -0700 (PDT) From: Chandrakanth Patil To: linux-scsi@vger.kernel.org Cc: kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, Chandrakanth Patil Subject: [PATCH v2 2/5] megaraid_sas: Fix the resource leak in case of probe failure Date: Fri, 21 May 2021 15:55:45 +0530 Message-Id: <20210521102548.11156-3-chandrakanth.patil@broadcom.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20210521102548.11156-1-chandrakanth.patil@broadcom.com> References: <20210521102548.11156-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; } }