Skip to content

Commit

Permalink
drm/xe: Fix bo leak in intel_fb_bo_framebuffer_init
Browse files Browse the repository at this point in the history
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 <[email protected]>
Fixes: 44e6949 ("drm/xe/display: Implement display support")
Cc: <[email protected]> # v6.8+
Reviewed-by: Nirmoy Das <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
(cherry picked from commit a2f3d73)
Signed-off-by: Lucas De Marchi <[email protected]>
  • Loading branch information
mlankhorst authored and lucasdemarchi committed Apr 17, 2024
1 parent 0bbac3f commit 652ead9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/gpu/drm/xe/display/intel_fb_bo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_SCANOUT_BIT)) {
/*
Expand All @@ -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_SCANOUT_BIT;
}
ttm_bo_unreserve(&bo->ttm);
return 0;

err:
xe_bo_put(bo);
return ret;
}

Expand Down

0 comments on commit 652ead9

Please sign in to comment.