Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1084942lqd; Thu, 25 Apr 2024 05:50:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWYNh3dqVnSfr7rif5MJfpXELBQ6Hzv6Wns78lZgrkZWyWvX0REIz9Qzu0ZRIK6EU/TrJgiRKnOQa/P8Z6oRPbyaqjmFUucWxFxz4ApIg== X-Google-Smtp-Source: AGHT+IFy0wIGkUCmegHzyCSDD9nVsIjgyBBIkRAgR0vWmtlsZlHbSZFKux9/3qY1fOae4P7XOTgS X-Received: by 2002:a05:6a20:ba29:b0:1aa:674a:94e0 with SMTP id fa41-20020a056a20ba2900b001aa674a94e0mr4607561pzb.43.1714049443011; Thu, 25 Apr 2024 05:50:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714049442; cv=pass; d=google.com; s=arc-20160816; b=kQVAgTxna7lStmf0IjbWS8a1bIusB/+xyKl0uSpaKaREHb1j1yFDNpmwINmDwThrKp R8fTmwjoisgq3dRrdhnzbqx6asWAVenqu+JqlzL2M/dUBJW4NmlbocFAx+AR9pt9URTL n0aIOecRFLDpZQtG9bDil5Nw8r77YT7buB/qRvFEWejJZeEYWmPragHmPqg46c9TBJ+R UxuVWLbTZJkeQV+gzz/gqbGyLdJeczvN6XRP5ErWqwvSosdLiaTMdtg9wo8n/NfeSd7g gphlzBCVQNm8ZC2WPIWfPN4/Ubv1zBGuDtj2wvxiwIAwYGDZ6cbSNFQRHxW8Frby+wUF 0rxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=g8A/lrMUgUBxL40xEMC2iS5a4RC8Y8TIZdvFa4f+V0o=; fh=svueJjvnNVRhQUONq/E+d+p+xL4JvjPnKzv7bb7GZV4=; b=cu1mkhEVWc+skUuOODhOHB/0Cs7QZndi/VQCS921sbVo//jThkk8kCkoHhy6Pa+Aic +YTu2dow1lJm+2q+yfSx/NGbstvs9eolQlQiyjGnUV/rK8cQv28LZybfMH/JF49Cr9Ji /wyQ3gEvuxAGzsIiV80BvJL2Gf5G3qC3RQVVJJROtZ6GymSr+E8rS4pC43oNg8gb9fqH /0vzYt/4rpwvHBMYtDYNFTo1uC7NL6oRG2O9HF5gUCVo9pNe+V6A1KY0iPsEiFQxiFfb y/S2C/Lb1yM0u34jLKO9XLtv2/3/w5gdBGvygdC8HKlWQM3f79qzPyGyoDgoYVe4Jcz6 mPEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-158548-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158548-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b20-20020a170902d89400b001e445b8108csi12988852plz.391.2024.04.25.05.50.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 05:50:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158548-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-158548-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158548-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C148B28A9D6 for ; Thu, 25 Apr 2024 12:49:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 56DF9149C6E; Thu, 25 Apr 2024 12:48:50 +0000 (UTC) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 695D012C464 for ; Thu, 25 Apr 2024 12:48:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714049329; cv=none; b=J6WJaIrbyocczzXLD04dmP++c5CVNRArGi8GFM9HMLUf6SBAeTCcKHXgGqIVq3KwNupLpmva2AiZZcK2IVHwNTkMRhKuIgzhN/EqeWyyECSODmEeVa8Q0ZTzCXeiq+fXItDiAiMKZ/5QQcAd1wlAwIt+MSiwGbo+bjsc9qWES+k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714049329; c=relaxed/simple; bh=56GuX1VvdDZ565qUSX23GroPKhcN2bY0+fIJUAzIVwo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TqlVv4OBgCGuXM00J1IjslitUXug9/Fwos/xszhdX3cZ4+9F6Qmw9R8d/1PBtR5Ezfv9ab/VjCxs8kWoQQXdIOjeItkVPHedDRioBjU9dzfd1j/Swf2cfbtSD6mFpH0lmNSIECxIDUiRXy8mMxj32mn/jykt5Guym4GhiWqsAic= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500002.china.huawei.com (7.185.36.158) 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 --- 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; -- 2.33.0