[Intel-gfx] [RFC][PATCH 10/11] drm: Fix debugfs edid_override locking

Daniel Vetter daniel at ffwll.ch
Tue Mar 6 09:56:35 UTC 2018


On Tue, Feb 27, 2018 at 02:56:59PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
> 
> The edid is protected by mode_config.mutex. Grab the lock when frobbing
> the debugfs edid_override thing.
> 
> Cc: Keith Packard <keithp at keithp.com>
> Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>

Yup, this looks correct. A kerneldoc patch to update the locking rules
would be great.

Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>

> ---
>  drivers/gpu/drm/drm_debugfs.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
> index b2482818fee8..caac17145629 100644
> --- a/drivers/gpu/drm/drm_debugfs.c
> +++ b/drivers/gpu/drm/drm_debugfs.c
> @@ -275,11 +275,17 @@ static ssize_t connector_write(struct file *file, const char __user *ubuf,
>  static int edid_show(struct seq_file *m, void *data)
>  {
>  	struct drm_connector *connector = m->private;
> -	struct drm_property_blob *edid = connector->edid_blob_ptr;
> +	struct drm_property_blob *edid;
> +
> +	mutex_lock(&connector->dev->mode_config.mutex);
> +
> +	edid = connector->edid_blob_ptr;
>  
>  	if (connector->override_edid && edid)
>  		seq_write(m, edid->data, edid->length);
>  
> +	mutex_unlock(&connector->dev->mode_config.mutex);
> +
>  	return 0;
>  }
>  
> @@ -305,6 +311,8 @@ static ssize_t edid_write(struct file *file, const char __user *ubuf,
>  
>  	edid = (struct edid *) buf;
>  
> +	mutex_lock(&connector->dev->mode_config.mutex);
> +
>  	if (len == 5 && !strncmp(buf, "reset", 5)) {
>  		connector->override_edid = false;
>  		ret = drm_mode_connector_update_edid_property(connector, NULL);
> @@ -318,6 +326,8 @@ static ssize_t edid_write(struct file *file, const char __user *ubuf,
>  			connector->override_edid = true;
>  	}
>  
> +	mutex_unlock(&connector->dev->mode_config.mutex);
> +
>  	kfree(buf);
>  
>  	return (ret) ? ret : len;
> -- 
> 2.13.6
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the Intel-gfx mailing list