[PATCH 3/8] drm/panfrost: Fix a BO leak in panfrost_ioctl_mmap_bo()

Steven Price steven.price at arm.com
Fri Nov 29 14:26:08 UTC 2019


On 29/11/2019 13:59, Boris Brezillon wrote:
> We should release the reference we grabbed when an error occurs.
> 
> Fixes: 187d2929206e ("drm/panfrost: Add support for GPU heap allocations")
> Cc: <stable at vger.kernel.org>
> Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>

Reviewed-by: Steven Price <steven.price at arm.com>

> ---
>  drivers/gpu/drm/panfrost/panfrost_drv.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c
> index efc0a24d1f4c..2630c5027c63 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_drv.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
> @@ -303,14 +303,17 @@ static int panfrost_ioctl_mmap_bo(struct drm_device *dev, void *data,
>  	}
>  
>  	/* Don't allow mmapping of heap objects as pages are not pinned. */
> -	if (to_panfrost_bo(gem_obj)->is_heap)
> -		return -EINVAL;
> +	if (to_panfrost_bo(gem_obj)->is_heap) {
> +		ret = -EINVAL;
> +		goto out;
> +	}
>  
>  	ret = drm_gem_create_mmap_offset(gem_obj);
>  	if (ret == 0)
>  		args->offset = drm_vma_node_offset_addr(&gem_obj->vma_node);
> -	drm_gem_object_put_unlocked(gem_obj);
>  
> +out:
> +	drm_gem_object_put_unlocked(gem_obj);
>  	return ret;
>  }
>  
> 



More information about the dri-devel mailing list