Skip to content

Commit

Permalink
clk: hisilicon: hi3660:Fix potential NULL dereference in hi3660_stub_…
Browse files Browse the repository at this point in the history
…clk_probe()

platform_get_resource() may return NULL, add proper check to
avoid potential NULL dereferencing.

This is detected by Coccinelle semantic patch.

@@
expression pdev, res, n, t, e, e1, e2;
@@

res = platform_get_resource(pdev, t, n);
+ if (!res)
+   return -EINVAL;
... when != res == NULL
e = devm_ioremap(e1, res->start, e2);

Fixes: 4f16f7f ("clk: hisilicon: Add support for Hi3660 stub clocks")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
  • Loading branch information
Wei Yongjun authored and Stephen Boyd committed Mar 12, 2018
1 parent 56e1ee3 commit 9903e41
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/clk/hisilicon/clk-hi3660-stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ static int hi3660_stub_clk_probe(struct platform_device *pdev)
return PTR_ERR(stub_clk_chan.mbox);

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
return -EINVAL;
freq_reg = devm_ioremap(dev, res->start, resource_size(res));
if (!freq_reg)
return -ENOMEM;
Expand Down

0 comments on commit 9903e41

Please sign in to comment.