lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <tencent_0B346CE1589FE10E0110418896F129323709@qq.com>
Date: Mon, 05 Jan 2026 23:59:40 +0800
From: Felix Gu <gu_0233@...com>
To: "Rafael J. Wysocki" <rafael@...nel.org>, 
 Viresh Kumar <viresh.kumar@...aro.org>, 
 Matthias Brugger <matthias.bgg@...il.com>, 
 AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org, 
 linux-arm-kernel@...ts.infradead.org, linux-mediatek@...ts.infradead.org, 
 Felix Gu <gu_0233@...com>
Subject: [PATCH] cpufreq: mediatek-hw: Fix resource leaks in init function

In mtk_cpu_resources_init(), if mtk_cpu_create_freq_table() fails, the
function returns directly without releasing the resources.

Similarly, in mtk_cpufreq_hw_cpu_init(), if the driver returns -ENODEV,
 it fails to clean up. Fix this by calling mtk_cpufreq_hw_cpu_exit()
to properly release resources.

Signed-off-by: Felix Gu <gu_0233@...com>
---
 drivers/cpufreq/mediatek-cpufreq-hw.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/mediatek-cpufreq-hw.c b/drivers/cpufreq/mediatek-cpufreq-hw.c
index ae4500ab4891..f28a3de1604f 100644
--- a/drivers/cpufreq/mediatek-cpufreq-hw.c
+++ b/drivers/cpufreq/mediatek-cpufreq-hw.c
@@ -278,13 +278,15 @@ static int mtk_cpu_resources_init(struct platform_device *pdev,
 	ret = mtk_cpu_create_freq_table(pdev, data);
 	if (ret) {
 		dev_info(dev, "Domain-%d failed to create freq table\n", index);
-		return ret;
+		goto unmap_base;
 	}
 
 	policy->freq_table = data->table;
 	policy->driver_data = data;
 
 	return 0;
+unmap_base:
+	iounmap(base);
 release_region:
 	release_mem_region(res->start, resource_size(res));
 	return ret;
@@ -322,6 +324,8 @@ static int mtk_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
 		if (!(sig & CPUFREQ_HW_STATUS)) {
 			pr_info("cpufreq hardware of CPU%d is not enabled\n",
 				policy->cpu);
+			/* call mtk_cpufreq_hw_cpu_exit to cleanup the resource */
+			mtk_cpufreq_hw_cpu_exit(policy);
 			return -ENODEV;
 		}
 

---
base-commit: 52ae6ea5bd7c7286dcba463b6323b640b22af833
change-id: 20260105-mediatek-cpufreq-hw-a2afa5c8275a

Best regards,
-- 
Felix Gu <gu_0233@...com>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ