linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] clk: hisilicon: hi3660:Fix potential NULL dereference in hi3660_stub_clk_probe()
@ 2018-01-04  6:36 Wei Yongjun
  2018-01-05  3:59 ` Masahiro Yamada
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Wei Yongjun @ 2018-01-04  6:36 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Kaihua Zhong, Leo Yan, Ruyi Wang,
	Kai Zhao, Tao Wang
  Cc: Wei Yongjun, linux-clk

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: 4f16f7ff3bc0 ("clk: hisilicon: Add support for Hi3660 stub clocks")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/clk/hisilicon/clk-hi3660-stub.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/hisilicon/clk-hi3660-stub.c b/drivers/clk/hisilicon/clk-hi3660-stub.c
index 9b6c72b..e8b2c43 100644
--- a/drivers/clk/hisilicon/clk-hi3660-stub.c
+++ b/drivers/clk/hisilicon/clk-hi3660-stub.c
@@ -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;

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-03-12 22:13 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-04  6:36 [PATCH -next] clk: hisilicon: hi3660:Fix potential NULL dereference in hi3660_stub_clk_probe() Wei Yongjun
2018-01-05  3:59 ` Masahiro Yamada
2018-01-05  8:40   ` Leo Yan
2018-01-05  8:54     ` weiyongjun (A)
2018-01-05  9:47     ` Wangtao (Kevin, Kirin)
2018-01-05  9:50       ` Masahiro Yamada
2018-01-05 10:47         ` Wangtao (Kevin, Kirin)
2018-01-08  4:22         ` Leo Yan
2018-01-10 22:48           ` Stephen Boyd
2018-01-17  7:58             ` Leo Yan
2018-01-05  9:04 ` [PATCH -next v2] clk: hisilicon: Using devm_ioremap_resource() instead of devm_ioremap() Wei Yongjun
2018-03-12 22:13 ` [PATCH -next] clk: hisilicon: hi3660:Fix potential NULL dereference in hi3660_stub_clk_probe() Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).