Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1146708pxv; Fri, 9 Jul 2021 19:30:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOUcC33ULXuaDJ/sjlgwq7+fgxFBWGwstpr9JPrB3YBQ/E4hXcdtzEMnom/R1Lqa1lhmf6 X-Received: by 2002:a17:907:6218:: with SMTP id ms24mr33911155ejc.343.1625884202437; Fri, 09 Jul 2021 19:30:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884202; cv=none; d=google.com; s=arc-20160816; b=BL6mSCvOt9edJRVGI/4oHoTm2g/BZsH326nw6ftyDKZa1eh8JYUFc4seb2ls9XlHe9 R6elD4gDUWIOKivd3ZPhXP5yvak0uwvqS2FWGGeWvEVPL++RQgrJ1WuoQD1x+7P5corv hudDtnLDK112EfBqVnrxgb//EyqHxfY8H2fjMz/qYUfapglzQuzZQWDg5PBPBv+0uRnp GQ7NoP5wnCCXCN70EKbIvaR1Q6bnKOxsOYRT7FEN6ZEsYHO6Af3t+LHPzQ+LC5Eum5kn FTcthpYASuPlbJ21TDdM91pUNW4e9qo7BbVG8w2EqHR3k7HKUV8CEMlUp+PFYtQA45Z7 jmiQ== 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=/RFY7aLuJ3ctDJCVUdoL1SnJKLTq6gHwUkvhwA4V/zY=; b=swVlUgSu+zjsOfKCCIlL3lDIOjSxJpGDicC3CRBLkRecKhunjfS3JqL2n5tfqxpa93 R9oW6Mj19juB0iTWibO5IjUb+gdfvMSGTufIcbQpn7DRBQ22TlTb2j6xcv5xywpPvQ6G 6qdXj+Nkstw+vIT15OEJX5ckeFgj+16d4F5deveoUrftF5HrDOvA9Ndtt5EnXJdCR47l 39/NjxqkJcVOXAcGte4E9JzO5wBoFLhcm5/DwNXPBMuToa0VdnBIT/TXhOPz4ATO5G9V Caad2U4/hkuTP7ugL6Dzxp+cRbdEsJPoBr/+App8lHn/CSXAUbuE/5b0J6DiWOtvcBQ+ NFNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=m2jPKj8S; 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 s21si9290042ejy.697.2021.07.09.19.29.39; Fri, 09 Jul 2021 19:30:02 -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=m2jPKj8S; 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 S234078AbhGJCbe (ORCPT + 99 others); Fri, 9 Jul 2021 22:31:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:42616 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233847AbhGJC2h (ORCPT ); Fri, 9 Jul 2021 22:28:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 76C2C613E4; Sat, 10 Jul 2021 02:25:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883913; bh=peK/yRLGmU4j94WUdNqjbMXbEbJqgP3hCL91x9cS0hU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m2jPKj8S10Ig36lzUp77zY48HwvXvQ9nygEdWgWN2qCHfJ/qE7VFWX3OQaz9NEjwb jElKQeTYjSwRGEzkeT0Ka6lGMqGYYwK9Mg+1vaZYXecDK7ot/d83RI+OGKyIIdDM9i 8vkyh4CpvQVRBnFCKEwwjrhgtK+i1y7Q6XI6mDNNGbzzdRvMFOEKILaywSwtQwS7Fw vsDuTG635rE3I54dW9nQTZt5sujkH4OYWvr+gsLhfwGATXlSdw06RJQAV7c+YLqs89 xyOQxVQJem4SATtmqwwdO8j6QPoSlmuyaHd2348Cz/EhUEqedNPm2qcRRsImqwbmJ5 UELaAGvXam7hw== 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.10 34/93] scsi: megaraid_sas: Fix resource leak in case of probe failure Date: Fri, 9 Jul 2021 22:23:28 -0400 Message-Id: <20210710022428.3169839-34-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022428.3169839-1-sashal@kernel.org> References: <20210710022428.3169839-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 cc45cdac1384..e58b0e558981 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -7439,11 +7439,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); @@ -7451,8 +7456,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 b0c01cf0428f..35925e68bf55 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -5193,6 +5193,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