Skip to contentSkip to conversation

cpufreq: mediatek-hw: Fix resource management and error handling in mtk_cpu_resources_init()

PATCH In review Riyan Dhiman 2 participants 4 messages Sep 6, 2024 – Sep 7, 2024 CPU frequency scaling framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpufreq: mediatek-hw: Fix resource management and error handling in mtk_cpu_resources_init()

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.

---
 drivers/cpufreq/mediatek-cpufreq-hw.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/cpufreq/mediatek-cpufreq-hw.c +3 -1
index 8925e096d5b9..3b1303f350ec 100644
@@ -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;
Signature · 1 line
2.46.0
#1 lore raw
Quoted 3 lines

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.

* Would you like to improve such a change description another bit also according to other line length preferences?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.11-rc6#n94

* How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?

Regards,
Markus

#2 lore raw

PATCH 1/1 cpufreq: mediatek-hw: Fix resource management and error handling in mtk_cpu_resources_init()

Quoted 5 lines
Quoted 3 lines

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.

* Would you like to improve such a change description another bit

Should I elaborate a little more on the issue and explain the fix I have created?

Quoted 1 line

also according to other line length preferences?

Can you please help me a little bit about this? Is it the character lenght of subject? should I change it to: cpufreq: mediatek: Fix resource leaks on mtk_cpu_create_freq_table() failure.

Quoted 1 line

* How do you think about to add any tags (like "Fixes" and "Cc") accordingly?

Should I change "patch" in subject to "Fixes" or add commit id in the patch message with fixes tag? Also, whom should add I in cc since I can't find any other email from get_maintainer script.

Regards,
Riyan Dhiman

#3 lore raw
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

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.

* Would you like to improve such a change description another bit

Should I elaborate a little more on the issue and explain the fix I have created?

Please take another look at guidance from linked information sources.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.11-rc6#n94

Quoted 3 lines
Quoted 1 line

also according to other line length preferences?

Can you please help me a little bit about this?

Yes, of course.

Quoted 1 line

Is it the character lenght of subject?

Not directly.

The summary phrase can eventually become more succinct.

Quoted 3 lines
Quoted 1 line

* How do you think about to add any tags (like "Fixes" and "Cc") accordingly?

Should I change "patch" in subject to "Fixes" or …

Obviously not.

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.11-rc6#n145

Regards,
Markus