Skip to content

Commit 9903e41

Browse files
Wei Yongjunbebarino
authored andcommitted
clk: hisilicon: hi3660:Fix potential NULL dereference in hi3660_stub_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 <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 56e1ee3 commit 9903e41

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/clk/hisilicon/clk-hi3660-stub.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ static int hi3660_stub_clk_probe(struct platform_device *pdev)
149149
return PTR_ERR(stub_clk_chan.mbox);
150150

151151
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
152+
if (!res)
153+
return -EINVAL;
152154
freq_reg = devm_ioremap(dev, res->start, resource_size(res));
153155
if (!freq_reg)
154156
return -ENOMEM;

0 commit comments

Comments
 (0)