diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-03-07 18:01:06 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-03-08 09:14:53 +0100 |
commit | f76ac178ee5390ed815b6a561bb913cca16aae2b (patch) | |
tree | f45568d016021472a149ddf89846da0187501cf1 | |
parent | 383f9f2d5d8db19dce05c982fa7fbfb44989ef53 (diff) | |
download | barebox-f76ac178ee5390ed815b6a561bb913cca16aae2b.tar.gz barebox-f76ac178ee5390ed815b6a561bb913cca16aae2b.tar.xz |
clk: composite: fix possible NULL pointer dereference
A composite clock is at most composed of a mux, a divider and a gate,
but it may lack one or two of these components. In that case, a NULL
pointer is passed, so we need to deal with this case.
Fixes: 8b0ca7a885ea ("clk: composite: add clk_hw registration functions")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220307170106.3937198-2-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | drivers/clk/clk-composite.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c index 63056b7696..4ebdd399b4 100644 --- a/drivers/clk/clk-composite.c +++ b/drivers/clk/clk-composite.c @@ -181,9 +181,13 @@ struct clk_hw *clk_hw_register_composite(struct device_d *dev, unsigned long flags) { struct clk *clk; - mux_hw->clk.ops = mux_ops; - rate_hw->clk.ops = rate_ops; - gate_hw->clk.ops = gate_ops; + + if (mux_hw) + mux_hw->clk.ops = mux_ops; + if (rate_hw) + rate_hw->clk.ops = rate_ops; + if (gate_hw) + gate_hw->clk.ops = gate_ops; parent_names = memdup_array(parent_names, num_parents); if (!parent_names) |