[RFC PATCH] drm: hide unregistered connectors from GETCONNECTOR IOCTL

Lyude Paul lyude at redhat.com
Mon Aug 1 20:32:29 UTC 2022


Yikes! Surprised this wasn't noticed until now. This lgtm:

Reviewed-by: Lyude Paul <lyude at redhat.com>

On Mon, 2022-08-01 at 13:38 +0000, Simon Ser wrote:
> When registering a connector, the kernel sends a hotplug uevent in
> drm_connector_register(). When unregistering a connector, drivers
> are expected to send a uevent as well. However, user-space has no way
> to figure out that the connector isn't registered anymore: it'll still
> be reported in GETCONNECTOR IOCTLs.
> 
> The documentation for DRM_CONNECTOR_UNREGISTERED states:
> 
> > The connector […] has since been unregistered and removed from
> > userspace, or the connector was unregistered before it had a chance
> > to be exposed to userspace
> 
> Signed-off-by: Simon Ser <contact at emersion.fr>
> Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
> Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
> Cc: Jani Nikula <jani.nikula at intel.com>
> ---
>  drivers/gpu/drm/drm_mode_config.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_mode_config.c
> b/drivers/gpu/drm/drm_mode_config.c
> index 688c8afe0bf1..939d621c9ad4 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -151,6 +151,9 @@ int drm_mode_getresources(struct drm_device *dev, void
> *data,
>         count = 0;
>         connector_id = u64_to_user_ptr(card_res->connector_id_ptr);
>         drm_for_each_connector_iter(connector, &conn_iter) {
> +               if (connector->registration_state !=
> DRM_CONNECTOR_REGISTERED)
> +                       continue;
> +
>                 /* only expose writeback connectors if userspace understands
> them */
>                 if (!file_priv->writeback_connectors &&
>                     (connector->connector_type ==
> DRM_MODE_CONNECTOR_WRITEBACK))

-- 
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat



More information about the dri-devel mailing list