Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1145065pxv; Fri, 9 Jul 2021 19:26:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZ0nAoAQx+rTLDBcyEBUJ3BoaLTCaPJbpNx6XN6aJy1ri5GtEfT/URpRt8lv05aMvWaH// X-Received: by 2002:a05:6402:280a:: with SMTP id h10mr33871178ede.87.1625884001090; Fri, 09 Jul 2021 19:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884001; cv=none; d=google.com; s=arc-20160816; b=RhLb6xZIMvfho0p1t4wHq/QKDUOHsLO2MKl/5FN01d8ZBVPwNfckiPR4doqNRwaExG nN+IDZ3dv0VgdchobL7lzytDl0q4+cpZaeuL5O5gm6eNl87ybNmcNL1bs70Ovd9cgCTS LnsfOYkxKPRDQ5X1vbJJkOpvSmByDrbX2u6q4kqxId6GXT1/RTUSx1x4vAIJOVUQkfoF m+BSryyATV2X9VKAWOZZknaUDkcJabZ7jH5ino3fjANqdODAlzzMVIdHcvehOzL8zUgp xiCeuMtT9qe+hlTUX8v4oL6mvL/5dY+v5xpd6ak7AcG57dB8VrAU9jX/8fOEi9h5YF91 zE8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jEOc0BRf+YfBEvJ2aS9gOH4Ypp7NRnWuUvls8OPfwig=; b=D4/TZjlFVSaD7wzvkXKS73vj1xrzpooMsZHiQPSrB6FT7MZyJfTnZvzMli03SUuS9C YGU0FFjP4aVPTo2NgupW7GvUv/9GmSNMQh2yieJAWCrfbzP7vc+d4JFWVG06M055Nl5E 6ToBCbY/50fC3uTRSqtDuR3cCFpZb753VhzZuxLu3i78mfMYKzsxqOuvAQcks6c0n9ik vNknSth6aCvYbkHcLsfLQYSuVngBE3MflReTNRvvcisbWnu1cn+boKFFpHRstasuRXxb lvX29rLPHOLmsg0Qe71SgsqWASIAAHV0e997Euk5BotrwaGe9IBzEoV4h4QzwofDs5Cz jU9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GXTgc1Cg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm21si9043651ejc.18.2021.07.09.19.26.17; Fri, 09 Jul 2021 19:26:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GXTgc1Cg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233505AbhGJC0T (ORCPT + 99 others); Fri, 9 Jul 2021 22:26:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:42574 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232810AbhGJCZ1 (ORCPT ); Fri, 9 Jul 2021 22:25:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2CE67613E8; Sat, 10 Jul 2021 02:22:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883763; bh=sCeIkDHHckfR4D+RnhHTSkVjSEPu2eJfdUuxc5HFrfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GXTgc1Cg1IOe1zMoil5T7COVrzpQmhGvX/4GLnsjtDwQI3RTwVd+VwSz6BqENhrwN aCwV5Ia47EI8DL2Ulo1pU4imwJwutlS7ApKDJwtKv5hNu7SzMi/A/RJCfmxT9p8TdN 3XbJR7gaJ0IR4w8hC75UuijkgKQD9Iqk+PakPzwcsQMY60hyZ9FwlHKgdNmnj0BIgA oPWKSkVW0dBW0wHivehGn0C1zKzXqAty6OHDOpCnWKUuTI/pIDsdY/bEYMvgq+dJGG KZA4c/ugV1soP6Hq1wJT9hp5IRBlb0wP2JMKibi4/OSQbT21F3kJCfGFealmPoeC4L FWCQAj2+2XlOw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Chandrakanth Patil , Sumit Saxena , "Martin K . Petersen" , Sasha Levin , megaraidlinux.pdl@broadcom.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 5.12 036/104] scsi: megaraid_sas: Fix resource leak in case of probe failure Date: Fri, 9 Jul 2021 22:20:48 -0400 Message-Id: <20210710022156.3168825-36-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022156.3168825-1-sashal@kernel.org> References: <20210710022156.3168825-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chandrakanth Patil [ Upstream commit b5438f48fdd8e1c3f130d32637511efd32038152 ] The driver doesn't clean up all the allocated resources properly when scsi_add_host(), megasas_start_aen() function fails during the PCI device probe. Clean up all those resources. Link: https://lore.kernel.org/r/20210528131307.25683-3-chandrakanth.patil@broadcom.com Signed-off-by: Chandrakanth Patil Signed-off-by: Sumit Saxena Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- 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 63a4f48bdc75..7ab741f03b84 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -7478,11 +7478,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); @@ -7490,8 +7495,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 38fc9467c625..f83bfc459fa1 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -5195,6 +5195,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; } } -- 2.30.2