Skip to contentSkip to conversation

drm/exynos: hdmi: free EDID on connector update failure

PATCH In review Avi Weiss 3 participants 5 messages Oct 12 – Nov 9

Subsystems (3)
lore
Share & tools
lore

Avi Weiss

author
#0 lore raw

PATCH 1/1 drm/exynos: hdmi: free EDID on connector update failure

If drm_edid_connector_update() fails, hdmi_get_modes() returns without freeing the EDID allocated by drm_edid_read_ddc(). It's an unlikely error path but nevertheless possible and should be cleaned up fully.

Free the EDID before returning, while keeping the existing return value of 0.

Fixes f6e4f57fd90dc ("drm/exynos: hdmi: convert to struct drm_edid")
---
 drivers/gpu/drm/exynos/exynos_hdmi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_hdmi.c +3 -1
index d4fce39c2b61..386557a7f5e8 100644
@@ -893,8 +893,10 @@ static int hdmi_get_modes(struct drm_connector *connector)
 	drm_edid = drm_edid_read_ddc(connector, hdata->ddc_adpt);
 
 	ret = drm_edid_connector_update(connector, drm_edid);
-	if (ret)
+	if (ret) {
+		drm_edid_free(drm_edid);
 		return 0;
+	}
 
 	cec_notifier_set_phys_addr(hdata->notifier, info->source_physical_address);
 

base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907

Signature · 1 line
2.43.0
#1 lore raw
Quoted 19 lines · Avi Weiss

If drm_edid_connector_update() fails, hdmi_get_modes() returns without freeing the EDID allocated by drm_edid_read_ddc(). It's an unlikely error path but nevertheless possible and should be cleaned up fully.

Free the EDID before returning, while keeping the existing return value of 0.

Fixes f6e4f57fd90dc ("drm/exynos: hdmi: convert to struct drm_edid")
---
 drivers/gpu/drm/exynos/exynos_hdmi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_hdmi.c +0 -0
index d4fce39c2b61..386557a7f5e8 100644

drivers/gpu/drm/exynos/exynos_hdmi.c static int hdmi_get_modes(struct drm_connector *connector) · line 895

Quoted 3 lines
drivers/gpu/drm/exynos/exynos_hdmi.c +0 -0
@@ -893,8 +893,10 @@ static int hdmi_get_modes(struct drm_connector *connector)
 	drm_edid = drm_edid_read_ddc(connector, hdata->ddc_adpt);
 
 	ret = drm_edid_connector_update(connector, drm_edid);

You could just move the drm_edid_free() call here to avoid duplicating it.

Quoted 10 lines
drivers/gpu/drm/exynos/exynos_hdmi.c +3 -1
-	if (ret)
+	if (ret) {
+		drm_edid_free(drm_edid);
 		return 0;
+	}
 
 	cec_notifier_set_phys_addr(hdata->notifier, info->source_physical_address);
 

base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907

Signature · 1 line
Jani Nikula, Intel
author
#2 lore raw

Hi Jani,
This complicates the if (!drm_edid) a bit further down, so might not be worth it.
What do you think? Leave it, or should I try to rework it? Cheers,
Avi

Quoted 41 lines · Jani Nikula
Quoted 19 lines · Avi Weiss

If drm_edid_connector_update() fails, hdmi_get_modes() returns without freeing the EDID allocated by drm_edid_read_ddc(). It's an unlikely error path but nevertheless possible and should be cleaned up fully.

Free the EDID before returning, while keeping the existing return value of 0.

Fixes f6e4f57fd90dc ("drm/exynos: hdmi: convert to struct drm_edid")
---
 drivers/gpu/drm/exynos/exynos_hdmi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_hdmi.c +0 -0
index d4fce39c2b61..386557a7f5e8 100644

drivers/gpu/drm/exynos/exynos_hdmi.c static int hdmi_get_modes(struct drm_connector *connector) · line 895

Quoted 3 lines
drivers/gpu/drm/exynos/exynos_hdmi.c +0 -0
@@ -893,8 +893,10 @@ static int hdmi_get_modes(struct drm_connector *connector)
      drm_edid = drm_edid_read_ddc(connector, hdata->ddc_adpt);
 
      ret = drm_edid_connector_update(connector, drm_edid);

You could just move the drm_edid_free() call here to avoid duplicating it.

Quoted 10 lines
drivers/gpu/drm/exynos/exynos_hdmi.c +3 -1
-     if (ret)
+     if (ret) {
+             drm_edid_free(drm_edid);
              return 0;
+     }
 
      cec_notifier_set_phys_addr(hdata->notifier, info->source_physical_address);
 

base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907

--
Jani Nikula, Intel

#3 lore raw
Quoted 4 lines · Avi Weiss

Hi Jani,
This complicates the if (!drm_edid) a bit further down, so might not be worth it.
What do you think? Leave it, or should I try to rework it?

Mmmh. Right, very few places actually check for drm_edid_connector_update() return value, or do anything about it.

Quoted 46 lines

Cheers,
Avi

Quoted 41 lines · Jani Nikula
Quoted 19 lines · Avi Weiss

If drm_edid_connector_update() fails, hdmi_get_modes() returns without freeing the EDID allocated by drm_edid_read_ddc(). It's an unlikely error path but nevertheless possible and should be cleaned up fully.

Free the EDID before returning, while keeping the existing return value of 0.

Fixes f6e4f57fd90dc ("drm/exynos: hdmi: convert to struct drm_edid")
---
 drivers/gpu/drm/exynos/exynos_hdmi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_hdmi.c +0 -0
index d4fce39c2b61..386557a7f5e8 100644

drivers/gpu/drm/exynos/exynos_hdmi.c static int hdmi_get_modes(struct drm_connector *connector) · line 895

Quoted 3 lines
drivers/gpu/drm/exynos/exynos_hdmi.c +0 -0
@@ -893,8 +893,10 @@ static int hdmi_get_modes(struct drm_connector *connector)
      drm_edid = drm_edid_read_ddc(connector, hdata->ddc_adpt);
 
      ret = drm_edid_connector_update(connector, drm_edid);

You could just move the drm_edid_free() call here to avoid duplicating it.

Quoted 10 lines
drivers/gpu/drm/exynos/exynos_hdmi.c +3 -1
-     if (ret)
+     if (ret) {
+             drm_edid_free(drm_edid);
              return 0;
+     }
 
      cec_notifier_set_phys_addr(hdata->notifier, info->source_physical_address);
 

base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907

--
Jani Nikula, Intel

Signature · 1 line
Jani Nikula, Intel
#4 lore raw
In reply to Avi Weiss

Hi,

2026년 10월 12일 (월) 오후 3:44, Avi Weiss <[email protected]>님이 작성:

Quoted 8 lines

If drm_edid_connector_update() fails, hdmi_get_modes() returns without freeing the EDID allocated by drm_edid_read_ddc(). It's an unlikely error path but nevertheless possible and should be cleaned up fully.

Free the EDID before returning, while keeping the existing return value of 0.

Merged.

Thanks,
Inki Dae

Quoted 29 lines
Fixes f6e4f57fd90dc ("drm/exynos: hdmi: convert to struct drm_edid")
---
 drivers/gpu/drm/exynos/exynos_hdmi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_hdmi.c +3 -1
index d4fce39c2b61..386557a7f5e8 100644
@@ -893,8 +893,10 @@ static int hdmi_get_modes(struct drm_connector *connector)
        drm_edid = drm_edid_read_ddc(connector, hdata->ddc_adpt);
 
        ret = drm_edid_connector_update(connector, drm_edid);
-       if (ret)
+       if (ret) {
+               drm_edid_free(drm_edid);
                return 0;
+       }
 
        cec_notifier_set_phys_addr(hdata->notifier, info->source_physical_address);
 

base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907 --
2.43.0