[PATCH] drm/xe: Fix bo leak in intel_fb_bo_framebuffer_init

Nirmoy Das nirmoy.das at linux.intel.com
Mon Apr 8 10:13:06 UTC 2024


On 4/4/2024 11:03 AM, Maarten Lankhorst wrote:
> Add a unreference bo in the error path, to prevent leaking a bo ref.
>
> Return 0 on success to clarify the success path.
>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
> Fixes: 44e694958b95 ("drm/xe/display: Implement display support")
> Cc: <stable at vger.kernel.org> # v6.8+
Reviewed-by: Nirmoy Das <nirmoy.das at intel.com>
> ---
>   drivers/gpu/drm/xe/display/intel_fb_bo.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/display/intel_fb_bo.c b/drivers/gpu/drm/xe/display/intel_fb_bo.c
> index dba327f53ac5..e18521acc516 100644
> --- a/drivers/gpu/drm/xe/display/intel_fb_bo.c
> +++ b/drivers/gpu/drm/xe/display/intel_fb_bo.c
> @@ -31,7 +31,7 @@ int intel_fb_bo_framebuffer_init(struct intel_framebuffer *intel_fb,
>   
>   	ret = ttm_bo_reserve(&bo->ttm, true, false, NULL);
>   	if (ret)
> -		return ret;
> +		goto err;
>   
>   	if (!(bo->flags & XE_BO_FLAG_SCANOUT)) {
>   		/*
> @@ -42,12 +42,16 @@ int intel_fb_bo_framebuffer_init(struct intel_framebuffer *intel_fb,
>   		 */
>   		if (XE_IOCTL_DBG(i915, !list_empty(&bo->ttm.base.gpuva.list))) {
>   			ttm_bo_unreserve(&bo->ttm);
> -			return -EINVAL;
> +			ret = -EINVAL;
> +			goto err;
>   		}
>   		bo->flags |= XE_BO_FLAG_SCANOUT;
>   	}
>   	ttm_bo_unreserve(&bo->ttm);
> +	return 0;
>   
> +err:
> +	xe_bo_put(bo);
>   	return ret;
>   }
>   


More information about the Intel-xe mailing list