Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3394e83 authored by Deepak Katragadda's avatar Deepak Katragadda Committed by David Collins
Browse files

clk: Add additional checking to some clock driver functions



Fix certain functions with potential for a NULL
pointer de-reference.

Change-Id: I855ef1d883a22616db7086bd5d47ee1f8e54694a
Signed-off-by: default avatarDeepak Katragadda <dkatraga@codeaurora.org>
Signed-off-by: default avatarDavid Dai <daidavid1@codeaurora.org>
Signed-off-by: default avatarDavid Collins <collinsd@codeaurora.org>
parent a41cfcca
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -295,6 +295,9 @@ static int clk_divider_bestdiv(struct clk_hw *hw, struct clk_hw *parent,
	unsigned long parent_rate, best = 0, now, maxdiv;
	unsigned long parent_rate_saved = *best_parent_rate;

	if (!hw || !parent)
		return -EINVAL;

	if (!rate)
		rate = 1;

+1 −2
Original line number Diff line number Diff line
@@ -954,15 +954,14 @@ static int clk_dp_set_rate(struct clk_hw *hw, unsigned long rate,
			unsigned long parent_rate)
{
	struct clk_rcg2 *rcg = to_clk_rcg2(hw);
	struct clk_hw *parent = clk_hw_get_parent(hw);
	struct freq_tbl f = { 0 };
	unsigned long src_rate;
	unsigned long num, den;
	u32 mask = BIT(rcg->hid_width) - 1;
	u32 hid_div, cfg;
	int i, num_parents = clk_hw_get_num_parents(hw);
	struct clk_hw *parent;

	parent = clk_hw_get_parent(hw);
	if (!parent)
		return -EINVAL;