mirror of
https://github.com/LineageOS/android_kernel_fxtec_sm6115.git
synced 2026-04-24 00:38:10 +00:00
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: Jagadeesh Kona <jkona@codeaurora.org>
This commit is contained in:
@ -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;
|
||||
|
||||
prate = clk_hw_get_rate(clk_hw_get_parent(hw));
|
||||
parent_hw = clk_hw_get_parent(hw);
|
||||
if (!parent_hw)
|
||||
return -EINVAL;
|
||||
|
||||
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);
|
||||
|
||||
@ -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 */
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user