Commit a2f3d731 authored by Maarten Lankhorst's avatar Maarten Lankhorst

drm/xe: Fix bo leak in intel_fb_bo_framebuffer_init

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: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Fixes: 44e69495 ("drm/xe/display: Implement display support")
Cc: <stable@vger.kernel.org> # v6.8+
Reviewed-by: default avatarNirmoy Das <nirmoy.das@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240404090302.68422-1-maarten.lankhorst@linux.intel.com
parent 4209d635
...@@ -31,7 +31,7 @@ int intel_fb_bo_framebuffer_init(struct intel_framebuffer *intel_fb, ...@@ -31,7 +31,7 @@ int intel_fb_bo_framebuffer_init(struct intel_framebuffer *intel_fb,
ret = ttm_bo_reserve(&bo->ttm, true, false, NULL); ret = ttm_bo_reserve(&bo->ttm, true, false, NULL);
if (ret) if (ret)
return ret; goto err;
if (!(bo->flags & XE_BO_FLAG_SCANOUT)) { if (!(bo->flags & XE_BO_FLAG_SCANOUT)) {
/* /*
...@@ -42,12 +42,16 @@ int intel_fb_bo_framebuffer_init(struct intel_framebuffer *intel_fb, ...@@ -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))) { if (XE_IOCTL_DBG(i915, !list_empty(&bo->ttm.base.gpuva.list))) {
ttm_bo_unreserve(&bo->ttm); ttm_bo_unreserve(&bo->ttm);
return -EINVAL; ret = -EINVAL;
goto err;
} }
bo->flags |= XE_BO_FLAG_SCANOUT; bo->flags |= XE_BO_FLAG_SCANOUT;
} }
ttm_bo_unreserve(&bo->ttm); ttm_bo_unreserve(&bo->ttm);
return 0;
err:
xe_bo_put(bo);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment