Message ID | 20241211230328.4012496-8-imre.deak@intel.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | drm/connector: Expose only a properly inited connector | expand |
On Thu, 12 Dec 2024, Imre Deak <imre.deak@intel.com> wrote: > After a connector is added to the drm_mode_config::connector_list, it's > visible to any in-kernel users looking up connectors via the above list. > Make sure that the connector is properly initialized before such > look-ups, by initializing the connector with > drm_connector_dynamic_register() - which doesn't add the connector to > the list - and registering it with drm_connector_dynamic_register() - > which adds the connector to the list - after the initialization is > complete. > > Cc: Karol Herbst <kherbst@redhat.com> > Cc: Lyude Paul <lyude@redhat.com> > Cc: Danilo Krummrich <dakr@kernel.org> > Signed-off-by: Imre Deak <imre.deak@intel.com> Reviewed-by: Jani Nikula <jani.nikula@intel.com> > --- > drivers/gpu/drm/nouveau/dispnv50/disp.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c > index eed579a6c858b..8097249612bc7 100644 > --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c > +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c > @@ -1265,8 +1265,8 @@ nv50_mstc_new(struct nv50_mstm *mstm, struct drm_dp_mst_port *port, > mstc->mstm = mstm; > mstc->port = port; > > - ret = drm_connector_init(dev, &mstc->connector, &nv50_mstc, > - DRM_MODE_CONNECTOR_DisplayPort); > + ret = drm_connector_dynamic_init(dev, &mstc->connector, &nv50_mstc, > + DRM_MODE_CONNECTOR_DisplayPort, NULL); > if (ret) { > kfree(*pmstc); > *pmstc = NULL;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c index eed579a6c858b..8097249612bc7 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c @@ -1265,8 +1265,8 @@ nv50_mstc_new(struct nv50_mstm *mstm, struct drm_dp_mst_port *port, mstc->mstm = mstm; mstc->port = port; - ret = drm_connector_init(dev, &mstc->connector, &nv50_mstc, - DRM_MODE_CONNECTOR_DisplayPort); + ret = drm_connector_dynamic_init(dev, &mstc->connector, &nv50_mstc, + DRM_MODE_CONNECTOR_DisplayPort, NULL); if (ret) { kfree(*pmstc); *pmstc = NULL;
After a connector is added to the drm_mode_config::connector_list, it's visible to any in-kernel users looking up connectors via the above list. Make sure that the connector is properly initialized before such look-ups, by initializing the connector with drm_connector_dynamic_register() - which doesn't add the connector to the list - and registering it with drm_connector_dynamic_register() - which adds the connector to the list - after the initialization is complete. Cc: Karol Herbst <kherbst@redhat.com> Cc: Lyude Paul <lyude@redhat.com> Cc: Danilo Krummrich <dakr@kernel.org> Signed-off-by: Imre Deak <imre.deak@intel.com> --- drivers/gpu/drm/nouveau/dispnv50/disp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)