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

Commit 070f2bf8 authored by Jagadeesh Kona's avatar Jagadeesh Kona
Browse files

clk: qcom: Fix possible NULL pointer dereferences



Add checks to properly handle and fix possible NULL pointer
dereferences and avoid usage of uninitialized variables.

Change-Id: I8c8fe1aa648e3f9fd6d7adf0ba55dc78d86ae25f
Signed-off-by: default avatarJagadeesh Kona <jkona@codeaurora.org>
parent e3e20132
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -918,8 +918,13 @@ static int alpha_pll_huayra_determine_rate(struct clk_hw *hw,
{
	unsigned long rrate, prate;
	u32 l, a;
	struct clk_hw *parent_hw;

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

	prate = clk_hw_get_rate(clk_hw_get_parent(hw));
	prate = clk_hw_get_rate(parent_hw);
	rrate = alpha_huayra_pll_round_rate(req->rate, prate, &l, &a);

	req->best_parent_hw = clk_hw_get_parent(hw);
+5 −1
Original line number Diff line number Diff line
@@ -1336,6 +1336,8 @@ static int clk_gfx3d_src_determine_rate(struct clk_hw *hw,
	int ret;

	xo = clk_hw_get_parent_by_index(hw, 0);
	if (!xo)
		return -EINVAL;
	if (req->rate == clk_hw_get_rate(xo)) {
		req->best_parent_hw = xo;
		req->best_parent_rate = req->rate;
@@ -1343,7 +1345,9 @@ static int clk_gfx3d_src_determine_rate(struct clk_hw *hw,
	}

	f = qcom_find_freq(rcg->freq_tbl, req->rate);
	if (!f || (req->rate != f->freq))
	if (!f)
		return -EINVAL;
	else if (req->rate != f->freq)
		req->rate = f->freq;

	/* Indexes of source from the parent map */
+2 −0
Original line number Diff line number Diff line
@@ -459,6 +459,8 @@ static int qcom_cpufreq_hw_read_lut(struct platform_device *pdev,
	base_freq = c->reg_bases[REG_FREQ_LUT_TABLE];
	base_volt = c->reg_bases[REG_VOLT_LUT_TABLE];

	prev_cc = 0;

	for (i = 0; i < lut_max_entries; i++) {
		data = readl_relaxed(base_freq + i * lut_row_size);
		src = (data & GENMASK(31, 30)) >> 30;