Messages in this thread Patch in this message | | | From | Claudiu Beznea <> | Subject | [PATCH 01/42] clk: at91: sama7g5: check __clk_get_hw() argument for errors | Date | Thu, 27 Jul 2023 08:31:15 +0300 |
| |
__clk_get_hw() argument in sama7g5 is obtained using of_clk_get_by_name() which might return error. Passing an error casted pointer to __clk_get_hw() may lead to crashes. Thus, check the pointer for errors before passing it to __clk_get_hw().
Fixes: de3383e993a5 ("clk: at91: sama7g5: switch to parent_hw and parent_data") Signed-off-by: Claudiu Beznea <claudiu.beznea@tuxon.dev> --- drivers/clk/at91/sama7g5.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/drivers/clk/at91/sama7g5.c b/drivers/clk/at91/sama7g5.c index 91b5c6f14819..16e458be8304 100644 --- a/drivers/clk/at91/sama7g5.c +++ b/drivers/clk/at91/sama7g5.c @@ -988,14 +988,27 @@ static void __init sama7g5_pmc_setup(struct device_node *np) struct clk_hw *td_slck_hw, *md_slck_hw; static struct clk_parent_data parent_data; struct clk_hw *parent_hws[10]; + struct clk *clk; bool bypass; int i, j; - td_slck_hw = __clk_get_hw(of_clk_get_by_name(np, "td_slck")); - md_slck_hw = __clk_get_hw(of_clk_get_by_name(np, "md_slck")); - main_xtal_hw = __clk_get_hw(of_clk_get_by_name(np, main_xtal_name)); - - if (!td_slck_hw || !md_slck_hw || !main_xtal_hw) + clk = of_clk_get_by_name(np, "td_slck"); + if (IS_ERR(clk)) + return; + td_slck_hw = __clk_get_hw(clk); + if (!td_slck_hw) + return; + clk = of_clk_get_by_name(np, "md_slck"); + if (IS_ERR(clk)) + return; + md_slck_hw = __clk_get_hw(clk); + if (!md_slck_hw) + return; + clk = of_clk_get_by_name(np, main_xtal_name); + if (IS_ERR(clk)) + return; + main_xtal_hw = __clk_get_hw(clk); + if (!main_xtal_hw) return; regmap = device_node_to_regmap(np); -- 2.39.2
| |