Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: ls1028a: fix a dereference of pointer 'parent' before a null check

Currently the pointer 'parent' is being dereferenced before it is
being null checked. Fix this by performing the null check before
it is dereferenced.

Addresses-Coverity: ("Dereference before null check")
Fixes: d37010a3c162 ("clk: ls1028a: Add clock driver for Display output interface")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lkml.kernel.org/r/20200203223736.99645-1-colin.king@canonical.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Colin Ian King and committed by
Stephen Boyd
73cb3106 2a8aa18c

+3 -1
+3 -1
drivers/clk/clk-plldig.c
··· 187 187 { 188 188 struct clk_plldig *data = to_clk_plldig(hw); 189 189 struct clk_hw *parent = clk_hw_get_parent(hw); 190 - unsigned long parent_rate = clk_hw_get_rate(parent); 190 + unsigned long parent_rate; 191 191 unsigned long val; 192 192 unsigned long long lltmp; 193 193 unsigned int mfd, fracdiv = 0; 194 194 195 195 if (!parent) 196 196 return -EINVAL; 197 + 198 + parent_rate = clk_hw_get_rate(parent); 197 199 198 200 if (data->vco_freq) { 199 201 mfd = data->vco_freq / parent_rate;