On Tue, Jun 28, 2011 at 11:27:47AM +0100, Chris Wilson wrote:
> As pointed out by Dan Carpenter, it was seemingly possible to hit an error
> whilst mapping the buffer for the regs (except the only likely error
> returns should not happen during init) and so leak a pin count on the
> bo. To handle this we would need to reacquire the struct mutex, so for
> simplicity rearrange for the lock to be held for the entire function.
> For extra pedagogy, test that we only call init once.
> 
> Signed-off-by: Chris Wilson <[email protected]>
Reviewed-by: Ben Widawsky <[email protected]>

> diff --git a/drivers/gpu/drm/i915/intel_overlay.c 
> b/drivers/gpu/drm/i915/intel_overlay.c
> index cffd3ed..d360380 100644
> --- a/drivers/gpu/drm/i915/intel_overlay.c
> +++ b/drivers/gpu/drm/i915/intel_overlay.c
> @@ -1405,6 +1405,11 @@ void intel_setup_overlay(struct drm_device *dev)
>       overlay = kzalloc(sizeof(struct intel_overlay), GFP_KERNEL);
>       if (!overlay)
>               return;
> +
> +     mutex_lock(&dev->struct_mutex);
> +     if (WARN_ON(dev_priv->overlay))
> +             goto out_free;
> +
>       overlay->dev = dev;
>  
>       reg_bo = i915_gem_alloc_object(dev, PAGE_SIZE);

For my curiosity, was there a reason you chose to acquire the lock after
the kzalloc?


_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to