Re: [PATCH] drm: Add missing drm_vblank_put() along queue vblank error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed,  1 Dec 2010 19:41:31 +0000
Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> wrote:

> Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
> Cc: Kristian HÃgsberg <krh@xxxxxxxxxxxxx>
> Cc: Jesse Barnes <jbarnes@xxxxxxxxxxxxxxxx>
> ---
>  drivers/gpu/drm/drm_irq.c |   19 ++++++++++++++-----
>  1 files changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 9d3a503..722700d 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -585,10 +585,13 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
>  	struct timeval now;
>  	unsigned long flags;
>  	unsigned int seq;
> +	int ret;
>  
>  	e = kzalloc(sizeof *e, GFP_KERNEL);
> -	if (e == NULL)
> -		return -ENOMEM;
> +	if (e == NULL) {
> +		ret = -ENOMEM;
> +		goto err_put;
> +	}
>  
>  	e->pipe = pipe;
>  	e->base.pid = current->pid;
> @@ -603,9 +606,8 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
>  	spin_lock_irqsave(&dev->event_lock, flags);
>  
>  	if (file_priv->event_space < sizeof e->event) {
> -		spin_unlock_irqrestore(&dev->event_lock, flags);
> -		kfree(e);
> -		return -ENOMEM;
> +		ret = -EBUSY;
> +		goto err_unlock;
>  	}
>  
>  	file_priv->event_space -= sizeof e->event;
> @@ -638,6 +640,13 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
>  	spin_unlock_irqrestore(&dev->event_lock, flags);
>  
>  	return 0;
> +
> +err_unlock:
> +	spin_unlock_irqrestore(&dev->event_lock, flags);
> +	kfree(e);
> +err_put:
> +	drm_vblank_put(dev, e->pipe);
> +	return ret;
>  }
>  
>  /**

Oh this is a good case to catch, since it's pretty easy to make
userspace request a bunch of events but never consume them, which will
eventually result in -ENOMEM returns from subsequent event request
calls.

Acked-by: Jesse Barnes <jbarnes@xxxxxxxxxxxxxxxx>

-- 
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux