Skip to contentSkip to conversation

drivers/clocksource/qcom: Add missing iounmap() on error when reading clock frequency.

PATCH In review Ankit Agrawal 2 participants 6 messages Jul 10, 2024 – Jul 12, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/clocksource/qcom: Add missing iounmap() on error when reading clock frequency.

Add the missing iounmap() when clock frequency fails to get read by the of_property_read_u32() call.

---
 drivers/clocksource/timer-qcom.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clocksource/timer-qcom.c +1 -0
index b4afe3a67..a66fa7f8e 100644
@@ -233,6 +233,7 @@ static int __init msm_dt_timer_init(struct device_node *np)
 	}
 
 	if (of_property_read_u32(np, "clock-frequency", &freq)) {
+		iounmap(cpu0_base);
 		pr_err("Unknown frequency\n");
 		return -EINVAL;
 	}
Signature · 1 line
2.25.1
#1 lore raw
Quoted 5 lines · Ankit Agrawal

Add the missing iounmap() when clock frequency fails to get read by the of_property_read_u32() call.

---

Or even better, you can extract:

drivers/platform/x86/intel/pmc/core_ssram.c 32:DEFINE_FREE(pmc_core_iounmap, void __iomem *, iounmap(_T));

into a common header, call it something less intel-specific and use it with __free() here

Konrad

#2 lore raw
Quoted 7 lines · Konrad Dybcio
Quoted 5 lines · Ankit Agrawal

Add the missing iounmap() when clock frequency fails to get read by the of_property_read_u32() call.

---

Quoted 7 lines

Or even better, you can extract:

drivers/platform/x86/intel/pmc/core_ssram.c 32:DEFINE_FREE(pmc_core_iounmap, void __iomem *, iounmap(_T));

into a common header, call it something less intel-specific and use it with __free() here

Can you please give a place where adding it would be appropriate? I am new to contributing here, so any guidance on where to add the DEFINE_FREE would be really helpful!

Also, just trying to think out loud. Will the cpu0_base pointer (and also the source_base pointer) be required once this function exits? If so, I think I will also need to use no_free_ptr() to ensure that the memory doesn't get iounmap-ed once the function exits.

Thanks!
Ankit

Reviewed-by
#3 lore raw
Quoted 13 lines · Ankit Agrawal
Quoted 12 lines · Konrad Dybcio
Quoted 5 lines · Ankit Agrawal

Add the missing iounmap() when clock frequency fails to get read by the of_property_read_u32() call.

---

Or even better, you can extract:

drivers/platform/x86/intel/pmc/core_ssram.c 32:DEFINE_FREE(pmc_core_iounmap, void __iomem *, iounmap(_T));

Quoted 6 lines
Quoted 2 lines

into a common header, call it something less intel-specific and use it with __free() here

Can you please give a place where adding it would be appropriate? I am new to contributing here, so any guidance on where to add the DEFINE_FREE would be really helpful!

I'd say include/linux/io.h sounds alright, but worst case scenario the maintainer of that file will ask you to move it somewhere else

Quoted 4 lines

Also, just trying to think out loud. Will the cpu0_base pointer (and also the source_base pointer) be required once this function exits? If so, I think I will also need to use no_free_ptr() to ensure that the memory doesn't get iounmap-ed once the function exits.

Ohh right source_base is a global variable.. perhaps the original patch here makes more sense given we definitely don't wanna unmap that..

So I'd say let's go with this one after all

Konrad

#4 lore raw
Quoted 3 lines · Konrad Dybcio
Quoted 2 lines · Ankit Agrawal
Quoted 1 line · Konrad Dybcio

On 10.07.2024 1:08 PM, Ankit Agrawal wrote:

[...]

Quoted 7 lines

Ohh right source_base is a global variable.. perhaps the original patch here makes more sense given we definitely don't wanna unmap that..

So I'd say let's go with this one after all

We should probably also check if msm_timer_init() succeeds and unmap if that fails.. we can just check the return value of that function and if it's non-zero, call iounmap

Konrad

#5 lore raw
Quoted 4 lines · Konrad Dybcio
Quoted 3 lines · Konrad Dybcio
Quoted 2 lines · Ankit Agrawal
Quoted 1 line · Konrad Dybcio

On 10.07.2024 1:08 PM, Ankit Agrawal wrote:

[...]

Quoted 4 lines

We should probably also check if msm_timer_init() succeeds and unmap if that fails.. we can just check the return value of that function and if it's non-zero, call iounmap

Sure. I have updated the patch accordingly. Please find version 2 of the patch here: https://lore.kernel.org/linux-arm-msm/20240712082747.GA182658@bnew-VirtualBox/

Thanks!
Ankit