diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c index 1007ce58e8b8..1d6bd7705050 100644 --- a/drivers/clk/qcom/clk-rcg2.c +++ b/drivers/clk/qcom/clk-rcg2.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2013, 2016-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2013, 2016-2018, 2020-2021, The Linux Foundation. All rights reserved. */ #include @@ -950,10 +950,11 @@ static int clk_byte2_determine_rate(struct clk_hw *hw, struct clk_hw *p; unsigned long rate = req->rate; - if (rate == 0) + p = req->best_parent_hw; + + if (!p || rate == 0) return -EINVAL; - p = req->best_parent_hw; req->best_parent_rate = parent_rate = clk_hw_round_rate(p, rate); div = DIV_ROUND_UP((2 * parent_rate), rate) - 1; @@ -1030,6 +1031,9 @@ static int clk_pixel_determine_rate(struct clk_hw *hw, int delta = 100000; const struct frac_entry *frac = frac_table_pixel; + if (!req->best_parent_hw) + return -EINVAL; + for (; frac->num; frac++) { request = (req->rate * frac->den) / frac->num;