Message ID | 20181220001959.12486-8-lyude@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | MST refcounting/atomic helpers cleanup | expand |
On 2018-12-19 7:19 p.m., Lyude Paul wrote: > Just like i915 and nouveau, it's a good idea for us to hold a malloc > reference to the port here so that we never pass a freed pointer to any > of the DP MST helper functions. > > Also, we stop unsetting aconnector->port in > dm_dp_destroy_mst_connector(). There's literally no point to that > assignment that I can see anyway. > > Signed-off-by: Lyude Paul <lyude@redhat.com> > Cc: Daniel Vetter <daniel@ffwll.ch> > Cc: David Airlie <airlied@redhat.com> > Cc: Jerry Zuo <Jerry.Zuo@amd.com> > Cc: Harry Wentland <harry.wentland@amd.com> > Cc: Juston Li <juston.li@intel.com> Reviewed-by: Harry Wentland <harry.wentland@amd.com> Harry > --- > .../drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c > index 5e7ca1f3a8d1..24632727e127 100644 > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c > @@ -191,6 +191,7 @@ dm_dp_mst_connector_destroy(struct drm_connector *connector) > drm_encoder_cleanup(&amdgpu_encoder->base); > kfree(amdgpu_encoder); > drm_connector_cleanup(connector); > + drm_dp_mst_put_port_malloc(amdgpu_dm_connector->port); > kfree(amdgpu_dm_connector); > } > > @@ -363,7 +364,9 @@ dm_dp_add_mst_connector(struct drm_dp_mst_topology_mgr *mgr, > amdgpu_dm_connector_funcs_reset(connector); > > DRM_INFO("DM_MST: added connector: %p [id: %d] [master: %p]\n", > - aconnector, connector->base.id, aconnector->mst_port); > + aconnector, connector->base.id, aconnector->mst_port); > + > + drm_dp_mst_get_port_malloc(port); > > DRM_DEBUG_KMS(":%d\n", connector->base.id); > > @@ -379,12 +382,12 @@ static void dm_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr, > struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector); > > DRM_INFO("DM_MST: Disabling connector: %p [id: %d] [master: %p]\n", > - aconnector, connector->base.id, aconnector->mst_port); > + aconnector, connector->base.id, aconnector->mst_port); > > - aconnector->port = NULL; > if (aconnector->dc_sink) { > amdgpu_dm_update_freesync_caps(connector, NULL); > - dc_link_remove_remote_sink(aconnector->dc_link, aconnector->dc_sink); > + dc_link_remove_remote_sink(aconnector->dc_link, > + aconnector->dc_sink); > dc_sink_release(aconnector->dc_sink); > aconnector->dc_sink = NULL; > } >
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c index 5e7ca1f3a8d1..24632727e127 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c @@ -191,6 +191,7 @@ dm_dp_mst_connector_destroy(struct drm_connector *connector) drm_encoder_cleanup(&amdgpu_encoder->base); kfree(amdgpu_encoder); drm_connector_cleanup(connector); + drm_dp_mst_put_port_malloc(amdgpu_dm_connector->port); kfree(amdgpu_dm_connector); } @@ -363,7 +364,9 @@ dm_dp_add_mst_connector(struct drm_dp_mst_topology_mgr *mgr, amdgpu_dm_connector_funcs_reset(connector); DRM_INFO("DM_MST: added connector: %p [id: %d] [master: %p]\n", - aconnector, connector->base.id, aconnector->mst_port); + aconnector, connector->base.id, aconnector->mst_port); + + drm_dp_mst_get_port_malloc(port); DRM_DEBUG_KMS(":%d\n", connector->base.id); @@ -379,12 +382,12 @@ static void dm_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr, struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector); DRM_INFO("DM_MST: Disabling connector: %p [id: %d] [master: %p]\n", - aconnector, connector->base.id, aconnector->mst_port); + aconnector, connector->base.id, aconnector->mst_port); - aconnector->port = NULL; if (aconnector->dc_sink) { amdgpu_dm_update_freesync_caps(connector, NULL); - dc_link_remove_remote_sink(aconnector->dc_link, aconnector->dc_sink); + dc_link_remove_remote_sink(aconnector->dc_link, + aconnector->dc_sink); dc_sink_release(aconnector->dc_sink); aconnector->dc_sink = NULL; }
Just like i915 and nouveau, it's a good idea for us to hold a malloc reference to the port here so that we never pass a freed pointer to any of the DP MST helper functions. Also, we stop unsetting aconnector->port in dm_dp_destroy_mst_connector(). There's literally no point to that assignment that I can see anyway. Signed-off-by: Lyude Paul <lyude@redhat.com> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: David Airlie <airlied@redhat.com> Cc: Jerry Zuo <Jerry.Zuo@amd.com> Cc: Harry Wentland <harry.wentland@amd.com> Cc: Juston Li <juston.li@intel.com> --- .../drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)