aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorWei Yongjun <weiyongjun1@huawei.com>2018-03-20 10:20:30 -0400
committerNeil Armstrong <narmstrong@baylibre.com>2018-03-20 12:15:40 -0400
commitacaa3f13b8dd77da3c6c0fe18cb1159eef7ea286 (patch)
tree0062ecc7d7aabc995ae2c976bd0afea09c50e279 /drivers/gpu
parentddc389f5a4abb4c0c91202cd6dc09a28b9e2d82c (diff)
drm/meson: Fix potential NULL dereference in meson_drv_bind_master()
platform_get_resource_byname() may fail and return NULL, so we should better check it's return value to avoid a NULL pointer dereference a bit later in the code. This is detected by Coccinelle semantic patch. @@ expression pdev, res, n, t, e, e1, e2; @@ res = platform_get_resource_byname(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: Neil Armstrong <narmstrong@baylibre.com> Acked-by: Neil Armstrong <narmstrong@baylibre.com> Link: https://patchwork.freedesktop.org/patch/msgid/1521555630-29284-1-git-send-email-weiyongjun1@huawei.com
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/meson/meson_drv.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
index 3baceb744beb..32b1a6cdecfc 100644
--- a/drivers/gpu/drm/meson/meson_drv.c
+++ b/drivers/gpu/drm/meson/meson_drv.c
@@ -197,6 +197,8 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
197 priv->io_base = regs; 197 priv->io_base = regs;
198 198
199 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hhi"); 199 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hhi");
200 if (!res)
201 return -EINVAL;
200 /* Simply ioremap since it may be a shared register zone */ 202 /* Simply ioremap since it may be a shared register zone */
201 regs = devm_ioremap(dev, res->start, resource_size(res)); 203 regs = devm_ioremap(dev, res->start, resource_size(res));
202 if (!regs) { 204 if (!regs) {
@@ -213,6 +215,8 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
213 } 215 }
214 216
215 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dmc"); 217 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dmc");
218 if (!res)
219 return -EINVAL;
216 /* Simply ioremap since it may be a shared register zone */ 220 /* Simply ioremap since it may be a shared register zone */
217 regs = devm_ioremap(dev, res->start, resource_size(res)); 221 regs = devm_ioremap(dev, res->start, resource_size(res));
218 if (!regs) { 222 if (!regs) {