Skip to contentSkip to conversation

drm/msm/hdmi: check return value after calling platform_get_resource_byname()

PATCH In review Yang Yingliang 3 participants 3 messages Apr 22, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/msm/hdmi: check return value after calling platform_get_resource_byname()

It will cause null-ptr-deref if platform_get_resource_byname() returns NULL, we need check the return value.

Fixes c6a57a50ad56 ("drm/msm/hdmi: add hdmi hdcp support (V3)")
---
 drivers/gpu/drm/msm/hdmi/hdmi.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/msm/hdmi/hdmi.c +4 -0
index ec324352e862..07e2ad527af9 100644
@@ -142,6 +142,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
 	/* HDCP needs physical address of hdmi register */
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
 		config->mmio_name);
+	if (!res) {
+		ret = -EINVAL;
+		goto fail;
+	}
 	hdmi->mmio_phy_addr = res->start;
 
 	hdmi->qfprom_mmio = msm_ioremap(pdev, config->qfprom_mmio_name);
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Yang Yingliang

It will cause null-ptr-deref if platform_get_resource_byname() returns NULL, we need check the return value.

Fixes c6a57a50ad56 ("drm/msm/hdmi: add hdmi hdcp support (V3)")
Quoted 19 lines
---
  drivers/gpu/drm/msm/hdmi/hdmi.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/gpu/drm/msm/hdmi/hdmi.c +4 -0
index ec324352e862..07e2ad527af9 100644
@@ -142,6 +142,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
  	/* HDCP needs physical address of hdmi register */
  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
  		config->mmio_name);
+	if (!res) {
+		ret = -EINVAL;
+		goto fail;
+	}
  	hdmi->mmio_phy_addr = res->start;
 
  	hdmi->qfprom_mmio = msm_ioremap(pdev, config->qfprom_mmio_name);
Reviewed-by on v1 1/1
#2 lore raw
In reply to Yang Yingliang
Quoted 6 lines · Yang Yingliang

It will cause null-ptr-deref if platform_get_resource_byname() returns NULL, we need check the return value.

Fixes c6a57a50ad56 ("drm/msm/hdmi: add hdmi hdcp support (V3)")
Quoted 22 lines
---
 drivers/gpu/drm/msm/hdmi/hdmi.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/msm/hdmi/hdmi.c +4 -1
index ec324352e862..07e2ad527af9 100644
@@ -142,6 +142,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
        /* HDCP needs physical address of hdmi register */
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
                config->mmio_name);
+       if (!res) {
+               ret = -EINVAL;
+               goto fail;
+       }
        hdmi->mmio_phy_addr = res->start;
 
        hdmi->qfprom_mmio = msm_ioremap(pdev, config->qfprom_mmio_name);
--

2.25.1

Signature · 2 lines
With best wishes
Dmitry