Skip to content

Commit 81640f0

Browse files
committed
drm/nouveau: Keep malloc references to MST ports
Now that we finally have a sane way to keep port allocations around, use it to fix the potential unchecked ->port accesses that nouveau makes by making sure we keep the mst port allocated for as long as it's drm_connector is accessible. Additionally, now that we've guaranteed that mstc->port is allocated for as long as we keep mstc around we can remove the connector registration checks for codepaths which release payloads, allowing us to release payloads on active topologies properly. These registration checks were only required before in order to avoid situations where mstc->port could technically be pointing at freed memory. Signed-off-by: Lyude Paul <lyude@redhat.com> Reviewed-by: Ben Skeggs <bskeggs@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> Link: https://patchwork.freedesktop.org/patch/msgid/20190111005343.17443-15-lyude@redhat.com
1 parent 5e292e7 commit 81640f0

File tree

1 file changed

+6
-0
lines changed
  • drivers/gpu/drm/nouveau/dispnv50

1 file changed

+6
-0
lines changed

drivers/gpu/drm/nouveau/dispnv50/disp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,11 @@ static void
956956
nv50_mstc_destroy(struct drm_connector *connector)
957957
{
958958
struct nv50_mstc *mstc = nv50_mstc(connector);
959+
959960
drm_connector_cleanup(&mstc->connector);
961+
if (mstc->port)
962+
drm_dp_mst_put_port_malloc(mstc->port);
963+
960964
kfree(mstc);
961965
}
962966

@@ -1004,6 +1008,7 @@ nv50_mstc_new(struct nv50_mstm *mstm, struct drm_dp_mst_port *port,
10041008
drm_object_attach_property(&mstc->connector.base, dev->mode_config.path_property, 0);
10051009
drm_object_attach_property(&mstc->connector.base, dev->mode_config.tile_property, 0);
10061010
drm_connector_set_path_property(&mstc->connector, path);
1011+
drm_dp_mst_get_port_malloc(port);
10071012
return 0;
10081013
}
10091014

@@ -1069,6 +1074,7 @@ nv50_mstm_destroy_connector(struct drm_dp_mst_topology_mgr *mgr,
10691074
drm_fb_helper_remove_one_connector(&drm->fbcon->helper, &mstc->connector);
10701075

10711076
drm_modeset_lock(&drm->dev->mode_config.connection_mutex, NULL);
1077+
drm_dp_mst_put_port_malloc(mstc->port);
10721078
mstc->port = NULL;
10731079
drm_modeset_unlock(&drm->dev->mode_config.connection_mutex);
10741080

0 commit comments

Comments
 (0)