All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Yongjun <weiyongjun1@huawei.com>
To: Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Kaihua Zhong <zhongkaihua@huawei.com>,
	Leo Yan <leo.yan@linaro.org>, Ruyi Wang <wangruyi@huawei.com>,
	Kai Zhao <zhaokai1@hisilicon.com>,
	Tao Wang <kevin.wangtao@hisilicon.com>
Cc: Wei Yongjun <weiyongjun1@huawei.com>, <linux-clk@vger.kernel.org>
Subject: [PATCH -next] clk: hisilicon: hi3660:Fix potential NULL dereference in hi3660_stub_clk_probe()
Date: Thu, 4 Jan 2018 06:36:34 +0000	[thread overview]
Message-ID: <1515047794-170174-1-git-send-email-weiyongjun1@huawei.com> (raw)

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;

             reply	other threads:[~2018-01-04  6:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-04  6:36 Wei Yongjun [this message]
2018-01-05  3:59 ` [PATCH -next] clk: hisilicon: hi3660:Fix potential NULL dereference in hi3660_stub_clk_probe() 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1515047794-170174-1-git-send-email-weiyongjun1@huawei.com \
    --to=weiyongjun1@huawei.com \
    --cc=kevin.wangtao@hisilicon.com \
    --cc=leo.yan@linaro.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@codeaurora.org \
    --cc=wangruyi@huawei.com \
    --cc=zhaokai1@hisilicon.com \
    --cc=zhongkaihua@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.