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>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240907163630.55704-1-riyandhiman14@gmail.com>
Date: Sat,  7 Sep 2024 22:06:30 +0530
From: Riyan Dhiman <riyandhiman14@...il.com>
To: rafael@...nel.org,
	viresh.kumar@...aro.org
Cc: linux-pm@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Riyan Dhiman <riyandhiman14@...il.com>
Subject: [PATCH v2] cpufreq: mediatek: Fix resource leaks on mtk_cpu_create_freq_table() failure

If mtk_cpu_create_freq_table() fails then there is a potential resource leak because 
memory region is not released and IO memory is not unmapped. 
Added error handling to ensure proper cleanup of all resources on failure, preventing potential leaks.

Fixes: d776790a5536 (cpufreq: mediatek-hw: Fix double devm_remap in hotplug case)

Signed-off-by: Riyan Dhiman <riyandhiman14@...il.com>
---
It is more of a extension of the above commit as this error handling was missing in that commit.

v2: Fix commit message.
v1: Added error handling.

 drivers/cpufreq/mediatek-cpufreq-hw.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/mediatek-cpufreq-hw.c b/drivers/cpufreq/mediatek-cpufreq-hw.c
index 8925e096d5b9..3b1303f350ec 100644
--- a/drivers/cpufreq/mediatek-cpufreq-hw.c
+++ b/drivers/cpufreq/mediatek-cpufreq-hw.c
@@ -207,13 +207,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_region;
 	}
 
 	policy->freq_table = data->table;
 	policy->driver_data = data;
 
 	return 0;
+unmap_region:
+	iounmap(base);
 release_region:
 	release_mem_region(res->start, resource_size(res));
 	return ret;
-- 
2.46.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ