Message ID | 20180103112049.4504-1-agust@denx.de |
---|---|
State | Accepted |
Commit | cca3ff054ab3e1f5f0d3f2d58da263cae201db50 |
Delegated to: | Anatolij Gustschin |
Headers | show |
Series | [U-Boot,v2,1/2] video: ipu: Fix dereferencing NULL pointer problem | expand |
On Wed, 3 Jan 2018 12:20:49 +0100 Anatolij Gustschin agust@denx.de wrote: > From: Peng Fan <peng.fan@nxp.com> > > The clk_set_rate function dereferences the clk pointer without > checking whether it is NULL. This may cause problem when clk is NULL. > > Signed-off-by: Peng Fan <peng.fan@nxp.com> > Signed-off-by: Anatolij Gustschin <agust@denx.de> > --- > Changes in v2: > - move the NULL check to top of function > > drivers/video/ipu_common.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) applied to u-boot-video/master, thanks! -- Anatolij
diff --git a/drivers/video/ipu_common.c b/drivers/video/ipu_common.c index 96229da502..889085aa76 100644 --- a/drivers/video/ipu_common.c +++ b/drivers/video/ipu_common.c @@ -132,8 +132,12 @@ struct clk *clk_get_parent(struct clk *clk) int clk_set_rate(struct clk *clk, unsigned long rate) { - if (clk && clk->set_rate) + if (!clk) + return 0; + + if (clk->set_rate) clk->set_rate(clk, rate); + return clk->rate; }