[PATCH] clocksource/drivers/exynos_mct: reject malformed local-timers property

Zhiqi Zhang zhiqizhangg at gmail.com
Tue Nov 24 21:03:23 PST 2026


The samsung,local-timers property is optional. When it is not present,
mct_init_dt() should keep using the default local timer indices.

of_property_count_u32_elems() returns a negative error both when the
property is absent and when it is present but malformed. The current
code handles any negative value as if the property were absent, so a
bad samsung,local-timers property is silently ignored instead of being
rejected.

Check for the property first. If it is present, propagate the parser
error or reject an empty array before programming the explicit local
timer indices. This preserves the default path for device trees that
omit the optional property.

I found this issue and reviewed the code change that OpenAI Codex
helped draft.

Fixes: 47dbe4eb9822 ("clocksource/drivers/exynos_mct: Support local-timers property")
Signed-off-by: Zhiqi Zhang <zhiqizhangg at gmail.com>
---
 drivers/clocksource/exynos_mct.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c
index da09f467a6..aee3d88ad3 100644
--- a/drivers/clocksource/exynos_mct.c
+++ b/drivers/clocksource/exynos_mct.c
@@ -645,10 +645,13 @@ static int __init mct_init_dt(struct device_node *np, unsigned int int_type)
 	int nr_local;
 	int ret;
 
-	nr_local = of_property_count_u32_elems(np, "samsung,local-timers");
-	if (nr_local == 0)
-		return -EINVAL;
-	if (nr_local > 0) {
+	if (of_property_present(np, "samsung,local-timers")) {
+		nr_local = of_property_count_u32_elems(np, "samsung,local-timers");
+		if (nr_local < 0)
+			return nr_local;
+		if (!nr_local)
+			return -EINVAL;
+
 		if (nr_local > ARRAY_SIZE(local_idx))
 			return -EINVAL;
 

base-commit: 7ccb044c27720d48175577080b851f047ddcfd1c
-- 
2.54.0 (Apple Git-157)




More information about the linux-arm-kernel mailing list