From patchwork Thu Apr 25 12:46:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junhao He X-Patchwork-Id: 13643287 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 73DC0C4345F for ; Thu, 25 Apr 2024 12:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pyHYlhc7T+3H0P0i7QCFSxp6kt7GuU5Otg0KRe4XRUo=; b=xz+OUROXUncIof /4/bTlKTk0ZaBbd1OAluoQIYTefoA+SK18eu4Xa1mp1sgmnrdgR9gVRQLxLxC6E6uKM+uPrI5hE8P 18R3wIzpQonHqXG8fmnSu++EQvYwD6aSHu1CB92dXitLauZHLvkmygscuZi2gutJCDszlhKrXki2w bsxCTrJxvPgGJPhFJcyTRYqIhQAPYyNEwyOrUSSc8WVZWZJVso1blHcKa7e11IHrLDr74uVD0/bPN 0h3NP5L/LqpoCmSfofTGlRF2euxP6WgFW51w2HGbci53+jkEL+2yWteJjB5EKWV67LlP7ENhh2vUJ xbc7OPnGqA4h2cLjW5qA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzyXO-00000008Iwv-3ugt; Thu, 25 Apr 2024 12:49:18 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzyXF-00000008Iqh-32Us for linux-arm-kernel@bombadil.infradead.org; Thu, 25 Apr 2024 12:49:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Content-Transfer-Encoding :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=g8A/lrMUgUBxL40xEMC2iS5a4RC8Y8TIZdvFa4f+V0o=; b=TbMnVzianRUgBHr0vW8Fz743NZ pIoXyEAlg/5ykQ6nGcdLdwOO2EOxiG4UX1gQi79+KtH2poE4wCbRbWLV+0ZBgGFXn34gaZZSUW2Xg lr1DPolG8mRg/oTSH9h44sTn/9iIxWOQRT3ne6fzgA54uNVgHhmLc52ZAjrQYehZyCr2jCsk3LIxp EmdKbSVUcB1nVKDmcNyFiJ9Y9/H9QC09eeyXvKK+XiGSukrhIOrDw6jk6op6L2zsFl09gmsgr5R+Y bZFEdb/GDc0jlSoI0BFhjnxrOrj5awN1NIIgsdGW65UD5TU3GXIb1vaHt6JlTBIGnVwLyrsTppIHv dFgHwLJA==; Received: from szxga02-in.huawei.com ([45.249.212.188]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzyXC-0000000EsN1-0rJk for linux-arm-kernel@lists.infradead.org; Thu, 25 Apr 2024 12:49:08 +0000 Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VQFtw2VTJzXmWW; Thu, 25 Apr 2024 20:45:12 +0800 (CST) Received: from dggpeml500002.china.huawei.com (unknown [7.185.36.158]) by mail.maildlp.com (Postfix) with ESMTPS id 74F1018007F; Thu, 25 Apr 2024 20:48:43 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by dggpeml500002.china.huawei.com (7.185.36.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 25 Apr 2024 20:48:43 +0800 From: Junhao He To: , , , CC: , , , , , Subject: [PATCH 3/3] drivers/perf: hisi: hns3: Actually use devm_add_action_or_reset() Date: Thu, 25 Apr 2024 20:46:27 +0800 Message-ID: <20240425124627.13764-4-hejunhao3@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240425124627.13764-1-hejunhao3@huawei.com> References: <20240425124627.13764-1-hejunhao3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500002.china.huawei.com (7.185.36.158) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240425_134906_708144_90C627D4 X-CRM114-Status: GOOD ( 11.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Hao Chen pci_alloc_irq_vectors() allocates an irq vector. When devm_add_action() fails, the irq vector is not freed, which leads to a memory leak. Replace the devm_add_action with devm_add_action_or_reset to ensure the irq vector can be destroyed when it fails. Fixes: 66637ab137b4 ("drivers/perf: hisi: add driver for HNS3 PMU") Signed-off-by: Hao Chen Signed-off-by: Junhao He Reviewed-by: Jijie Shao Acked-by: Jonathan Cameron --- drivers/perf/hisilicon/hns3_pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/perf/hisilicon/hns3_pmu.c b/drivers/perf/hisilicon/hns3_pmu.c index cbdd53b0a034..60062eaa342a 100644 --- a/drivers/perf/hisilicon/hns3_pmu.c +++ b/drivers/perf/hisilicon/hns3_pmu.c @@ -1527,7 +1527,7 @@ static int hns3_pmu_irq_register(struct pci_dev *pdev, return ret; } - ret = devm_add_action(&pdev->dev, hns3_pmu_free_irq, pdev); + ret = devm_add_action_or_reset(&pdev->dev, hns3_pmu_free_irq, pdev); if (ret) { pci_err(pdev, "failed to add free irq action, ret = %d.\n", ret); return ret;