All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: Add missing drm_vblank_put() along queue vblank error path
@ 2010-12-01 19:41 Chris Wilson
  2010-12-06 17:30 ` Jesse Barnes
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Wilson @ 2010-12-01 19:41 UTC (permalink / raw)
  To: dri-devel

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Kristian Høgsberg <krh@bitplanet.net>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
---
 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;
 }
 
 /**
-- 
1.7.2.3

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm: Add missing drm_vblank_put() along queue vblank error path
  2010-12-01 19:41 [PATCH] drm: Add missing drm_vblank_put() along queue vblank error path Chris Wilson
@ 2010-12-06 17:30 ` Jesse Barnes
  0 siblings, 0 replies; 2+ messages in thread
From: Jesse Barnes @ 2010-12-06 17:30 UTC (permalink / raw)
  To: Chris Wilson; +Cc: dri-devel

On Wed,  1 Dec 2010 19:41:31 +0000
Chris Wilson <chris@chris-wilson.co.uk> wrote:

> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Kristian Høgsberg <krh@bitplanet.net>
> Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
> ---
>  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@virtuousgeek.org>

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-12-06 17:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-01 19:41 [PATCH] drm: Add missing drm_vblank_put() along queue vblank error path Chris Wilson
2010-12-06 17:30 ` Jesse Barnes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.