[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220117084156.9338-1-kevin3.tang@gmail.com>
Date: Mon, 17 Jan 2022 16:41:56 +0800
From: Kevin Tang <kevin3.tang@...il.com>
To: maarten.lankhorst@...ux.intel.com, mripard@...nel.org,
airlied@...ux.ie, daniel@...ll.ch, mark.rutland@....com,
javierm@...hat.com, tzimmermann@...e.de, lukas.bulwahn@...il.com
Cc: zou_wei@...wei.com, kevin3.tang@...il.com, pony1.wu@...il.com,
orsonzhai@...il.com, dan.carpenter@...cle.com,
zhang.lyra@...il.com, linux-kernel@...r.kernel.org,
dri-devel@...ts.freedesktop.org, devicetree@...r.kernel.org
Subject: [PATCH v2 3/3] drm/sprd: check the platform_get_resource() return value
platform_get_resource() may fail and return NULL, so check it's value
before using it.
Reported-by: Zou Wei <zou_wei@...wei.com>
Signed-off-by: Kevin Tang <kevin.tang@...soc.com>
Reviewed-by: Javier Martinez Canillas <javierm@...hat.com>
Acked-by: Thomas Zimmermann <tzimmermann@...e.de>
v1 -> v2:
- new patch
---
drivers/gpu/drm/sprd/sprd_dpu.c | 5 +++++
drivers/gpu/drm/sprd/sprd_dsi.c | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/drivers/gpu/drm/sprd/sprd_dpu.c b/drivers/gpu/drm/sprd/sprd_dpu.c
index 06a3414ee..1637203ea 100644
--- a/drivers/gpu/drm/sprd/sprd_dpu.c
+++ b/drivers/gpu/drm/sprd/sprd_dpu.c
@@ -790,6 +790,11 @@ static int sprd_dpu_context_init(struct sprd_dpu *dpu,
int ret;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ dev_err(dev, "failed to get I/O resource\n");
+ return -EINVAL;
+ }
+
ctx->base = devm_ioremap(dev, res->start, resource_size(res));
if (!ctx->base) {
dev_err(dev, "failed to map dpu registers\n");
diff --git a/drivers/gpu/drm/sprd/sprd_dsi.c b/drivers/gpu/drm/sprd/sprd_dsi.c
index 911b3cddc..12b67a5d5 100644
--- a/drivers/gpu/drm/sprd/sprd_dsi.c
+++ b/drivers/gpu/drm/sprd/sprd_dsi.c
@@ -907,6 +907,11 @@ static int sprd_dsi_context_init(struct sprd_dsi *dsi,
struct resource *res;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ dev_err(dev, "failed to get I/O resource\n");
+ return -EINVAL;
+ }
+
ctx->base = devm_ioremap(dev, res->start, resource_size(res));
if (!ctx->base) {
drm_err(dsi->drm, "failed to map dsi host registers\n");
--
2.29.0
Powered by blists - more mailing lists