]> git.baikalelectronics.ru Git - uboot.git/commit
clk: Check that ops of composite clock components exist before calling
authorSean Anderson <seanga2@gmail.com>
Wed, 24 Jun 2020 10:41:07 +0000 (06:41 -0400)
committerAndes <uboot@andestech.com>
Wed, 1 Jul 2020 07:01:21 +0000 (15:01 +0800)
commita5e4f2edcdb69679700e1677441e1a0535b1defd
tree7c7737a0844418e2dd72cd8a7d14ea83664b2171
parentd4db6dfb7de53e1ac774dcc41e77cfec036e870d
clk: Check that ops of composite clock components exist before calling

clk_composite_ops was shared between all devices in the composite clock
driver.  If one clock had a feature (such as supporting set_parent) which
another clock did not, it could call a null pointer dereference.

This patch does three things
1. It adds null-pointer checks to all composite clock functions.
2. It makes clk_composite_ops const and sets its functions at compile-time.
3. It adds some basic sanity checks to num_parents.

The combined effect of these changes is that any of mux, rate, or gate can
be NULL, and composite clocks will still function normally. Previously, at
least mux had to exist, since clk_composite_get_parent was used to
determine the parent for clk_register.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Acked-by: Lukasz Majewski <lukma@denx.de>
drivers/clk/clk-composite.c