Skip to content

Commit 652ead9

Browse files
mlankhorstlucasdemarchi
authored andcommitted
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: 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]>
1 parent 0bbac3f commit 652ead9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/gpu/drm/xe/display/intel_fb_bo.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ int intel_fb_bo_framebuffer_init(struct intel_framebuffer *intel_fb,
3131

3232
ret = ttm_bo_reserve(&bo->ttm, true, false, NULL);
3333
if (ret)
34-
return ret;
34+
goto err;
3535

3636
if (!(bo->flags & XE_BO_SCANOUT_BIT)) {
3737
/*
@@ -42,12 +42,16 @@ int intel_fb_bo_framebuffer_init(struct intel_framebuffer *intel_fb,
4242
*/
4343
if (XE_IOCTL_DBG(i915, !list_empty(&bo->ttm.base.gpuva.list))) {
4444
ttm_bo_unreserve(&bo->ttm);
45-
return -EINVAL;
45+
ret = -EINVAL;
46+
goto err;
4647
}
4748
bo->flags |= XE_BO_SCANOUT_BIT;
4849
}
4950
ttm_bo_unreserve(&bo->ttm);
51+
return 0;
5052

53+
err:
54+
xe_bo_put(bo);
5155
return ret;
5256
}
5357

0 commit comments

Comments
 (0)