[PATCH 06/10] clk: gpio: Reject gate clocks with multiple parents
From: Lee Jones
Date: Mon Nov 23 2026 - 11:49:35 EST
gpio_clk_driver_probe() verifies that a gpio-mux-clock has exactly two
parents, but passes an unvalidated parent count for a gpio-gate-clock
into clk_register_gpio(). clk_register_gpio() points init.parent_data
at a two-element stack array, so a gate clock node specifying more than
two parents causes clk_core_populate_parent_map() to read past the end
of the stack buffer during registration.
A GPIO gate clock has no parent selection ops and its binding permits at
most one parent clock. Reject gate clocks with more than one parent in
gpio_clk_driver_probe().
Fixes: 9a9b5a4af066 ("clk: gpio: Use DT way of specifying parents")
Closes: https://sashiko.dev/#/bug/linux-99ca4204-ff53-407a-8c2c-157738e7babb
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/clk/clk-gpio.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c
index df0856a39c8d..2337e8a093f0 100644
--- a/drivers/clk/clk-gpio.c
+++ b/drivers/clk/clk-gpio.c
@@ -208,6 +208,9 @@ static int gpio_clk_driver_probe(struct platform_device *pdev)
if (is_mux && num_parents != 2) {
dev_err(dev, "mux-clock must have 2 parents\n");
return -EINVAL;
+ } else if (!is_mux && num_parents > 1) {
+ return dev_err_probe(dev, -EINVAL,
+ "gate-clock must have at most 1 parent\n");
}
gpio_name = is_mux ? "select" : "enable";
--
2.56.1.750.gf70dc682cf-goog