public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Riyan Dhiman <riyandhiman14@gmail.com>
To: rafael@kernel.org, viresh.kumar@linaro.org
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Riyan Dhiman <riyandhiman14@gmail.com>
Subject: [PATCH] cpufreq: mediatek-hw: Fix resource management and error handling in mtk_cpu_resources_init()
Date: Fri,  6 Sep 2024 14:10:57 +0530	[thread overview]
Message-ID: <20240906084057.67680-1-riyandhiman14@gmail.com> (raw)

Memory region and IO memory were not released if mtk_cpu_create_freq_table() failed.
Added error handling to ensure that IO memory is unmapped and the memory region is
released properly to prevent resource leaks and ensure all resources are cleaned up on error.

Signed-off-by: Riyan Dhiman <riyandhiman14@gmail.com>
---
 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


             reply	other threads:[~2024-09-06  8:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-06  8:40 Riyan Dhiman [this message]
2024-09-07 11:52 ` [PATCH] cpufreq: mediatek-hw: Fix resource management and error handling in mtk_cpu_resources_init() Markus Elfring
2024-09-07 15:42   ` Riyan Dhiman
2024-09-07 16:10     ` Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240906084057.67680-1-riyandhiman14@gmail.com \
    --to=riyandhiman14@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox