Skip to contentSkip to conversation

drm: i915: fix a possible refcount leak in intel_dp_add_mst_connector()

PATCH Superseded Hangyu Hua 2 participants 4 messages May 16, 2022 – Jun 23, 2022

Subsystems (3)
lore
Share & tools
lore

Hangyu Hua

author
#0 lore raw

PATCH 1/1 drm: i915: fix a possible refcount leak in intel_dp_add_mst_connector()

If drm_connector_init fails, intel_connector_free will be called to take care of proper free. So it is necessary to drop the refcount of port before intel_connector_free.

Fixes 091a4f91942a ("drm/i915: Handle drm-layer errors in intel_dp_add_mst_connector")
---
 drivers/gpu/drm/i915/display/intel_dp_mst.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/display/intel_dp_mst.c +1 -0
index e30e698aa684..f7d46ea3afb9 100644
@@ -841,6 +841,7 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo
 	ret = drm_connector_init(dev, connector, &intel_dp_mst_connector_funcs,
 				 DRM_MODE_CONNECTOR_DisplayPort);
 	if (ret) {
+		drm_dp_mst_put_port_malloc(port);
 		intel_connector_free(intel_connector);
 		return NULL;
 	}
Signature · 1 line
2.25.1
author
#1 lore raw
Quoted 15 lines · Hangyu Hua

If drm_connector_init fails, intel_connector_free will be called to take care of proper free. So it is necessary to drop the refcount of port before intel_connector_free.

Fixes 091a4f91942a ("drm/i915: Handle drm-layer errors in intel_dp_add_mst_connector")
---
  drivers/gpu/drm/i915/display/intel_dp_mst.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/display/intel_dp_mst.c +0 -0
index e30e698aa684..f7d46ea3afb9 100644

drivers/gpu/drm/i915/display/intel_dp_mst.c static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo · line 847

Quoted 7 lines
drivers/gpu/drm/i915/display/intel_dp_mst.c +1 -0
@@ -841,6 +841,7 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo
  	ret = drm_connector_init(dev, connector, &intel_dp_mst_connector_funcs,
  				 DRM_MODE_CONNECTOR_DisplayPort);
  	if (ret) {
+		drm_dp_mst_put_port_malloc(port);
  		intel_connector_free(intel_connector);
  		return NULL;
  	}

Gentel ping.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Hangyu Hua
Quoted 3 lines · Hangyu Hua

If drm_connector_init fails, intel_connector_free will be called to take care of proper free. So it is necessary to drop the refcount of port before intel_connector_free.

Quoted 19 lines
Fixes 091a4f91942a ("drm/i915: Handle drm-layer errors in intel_dp_add_mst_connector")
---
 drivers/gpu/drm/i915/display/intel_dp_mst.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/display/intel_dp_mst.c +1 -0
index e30e698aa684..f7d46ea3afb9 100644
@@ -841,6 +841,7 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo
 	ret = drm_connector_init(dev, connector, &intel_dp_mst_connector_funcs,
 				 DRM_MODE_CONNECTOR_DisplayPort);
 	if (ret) {
+		drm_dp_mst_put_port_malloc(port);
 		intel_connector_free(intel_connector);
 		return NULL;
 	}
#3 lore raw
Quoted 6 lines · Jose
Quoted 3 lines · Hangyu Hua

If drm_connector_init fails, intel_connector_free will be called to take care of proper free. So it is necessary to drop the refcount of port before intel_connector_free.

Don't know why but our CI did not caught your patch.
Can you please resend it with my Reviewed-by to [email protected] ?

Quoted 21 lines
Quoted 20 lines
Fixes 091a4f91942a ("drm/i915: Handle drm-layer errors in intel_dp_add_mst_connector")
---
 drivers/gpu/drm/i915/display/intel_dp_mst.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/display/intel_dp_mst.c +1 -0
index e30e698aa684..f7d46ea3afb9 100644
@@ -841,6 +841,7 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo
 	ret = drm_connector_init(dev, connector, &intel_dp_mst_connector_funcs,
 				 DRM_MODE_CONNECTOR_DisplayPort);
 	if (ret) {
+		drm_dp_mst_put_port_malloc(port);
 		intel_connector_free(intel_connector);
 		return NULL;
 	}