diff options
author | weiyongjun (A) <weiyongjun1@huawei.com> | 2018-01-04 20:50:59 -0500 |
---|---|---|
committer | Stephen Boyd <sboyd@codeaurora.org> | 2018-01-10 16:24:36 -0500 |
commit | 9d548d80384732bad74c3046329e5dbdae098104 (patch) | |
tree | 2373e0e1db880e20502628bbe6aec11a5f20615e /drivers/clk/meson | |
parent | 348c898cb897d6663548aada9d68c0d2d7cfba8e (diff) |
clk: meson-axg: fix potential NULL dereference in axg_clkc_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);
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Diffstat (limited to 'drivers/clk/meson')
-rw-r--r-- | drivers/clk/meson/axg.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c index d883bef49eb7..1294f3ad7cd5 100644 --- a/drivers/clk/meson/axg.c +++ b/drivers/clk/meson/axg.c | |||
@@ -879,6 +879,8 @@ static int axg_clkc_probe(struct platform_device *pdev) | |||
879 | 879 | ||
880 | /* Generic clocks and PLLs */ | 880 | /* Generic clocks and PLLs */ |
881 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 881 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
882 | if (!res) | ||
883 | return -EINVAL; | ||
882 | clk_base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); | 884 | clk_base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); |
883 | if (!clk_base) { | 885 | if (!clk_base) { |
884 | dev_err(&pdev->dev, "Unable to map clk base\n"); | 886 | dev_err(&pdev->dev, "Unable to map clk base\n"); |