[PATCH v12 2/3] clk: validate spread spectrum configuration

From: Dario Binacchi

Date: Wed Sep 02 2026 - 06:24:07 EST


The spread spectrum configuration is passed to the provider's
set_spread_spectrum() callback without any validation, as clk-conf.c
only skips all-zero triplets from "assigned-clock-sscs". An invalid
device tree can hand providers a zero modulation frequency or a spread
ratio above 100%, and each provider would have to add the same checks
to protect e.g. divisions in its rate computations.

Fixes: c86814e70390 ("clk: Introduce clk_hw_set_spread_spectrum")
Signed-off-by: Dario Binacchi <dario.binacchi@xxxxxxxxxxxxxxxxxxxx>
---

(no changes since v1)

drivers/clk/clk.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index fef87167a60b..208caf60eeb5 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2851,6 +2851,20 @@ int clk_hw_set_spread_spectrum(struct clk_hw *hw, const struct clk_spread_spectr
if (!hw)
return 0;

+ switch (ss_conf->method) {
+ case CLK_SPREAD_NO:
+ break;
+ case CLK_SPREAD_CENTER:
+ case CLK_SPREAD_UP:
+ case CLK_SPREAD_DOWN:
+ if (!ss_conf->modfreq_hz || !ss_conf->spread_bp ||
+ ss_conf->spread_bp > 10000)
+ return -EINVAL;
+ break;
+ default:
+ return -EINVAL;
+ }
+
core = hw->core;

clk_prepare_lock();
--
2.43.0