Skip to content

Commit 5d5e100

Browse files
sherllyrodrigovivi
authored andcommitted
drm/i915/selftests: Fix i915_address_space refcnt leak
igt_ppgtt_pin_update() invokes i915_gem_context_get_vm_rcu(), which returns a reference of the i915_address_space object to "vm" with increased refcount. When igt_ppgtt_pin_update() returns, "vm" becomes invalid, so the refcount should be decreased to keep refcount balanced. The reference counting issue happens in two exception handling paths of igt_ppgtt_pin_update(). When i915_gem_object_create_internal() returns IS_ERR, the refcnt increased by i915_gem_context_get_vm_rcu() is not decreased, causing a refcnt leak. Fix this issue by jumping to "out_vm" label when i915_gem_object_create_internal() returns IS_ERR. Fixes: a4e7ccd ("drm/i915: Move context management under GEM") Signed-off-by: Xiyu Yang <[email protected]> Signed-off-by: Xin Tan <[email protected]> Reviewed-by: Chris Wilson <[email protected]> Signed-off-by: Chris Wilson <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit e07c760) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent d082119 commit 5d5e100

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/gpu/drm/i915/gem/selftests/huge_pages.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,8 +1477,10 @@ static int igt_ppgtt_pin_update(void *arg)
14771477
unsigned int page_size = BIT(first);
14781478

14791479
obj = i915_gem_object_create_internal(dev_priv, page_size);
1480-
if (IS_ERR(obj))
1481-
return PTR_ERR(obj);
1480+
if (IS_ERR(obj)) {
1481+
err = PTR_ERR(obj);
1482+
goto out_vm;
1483+
}
14821484

14831485
vma = i915_vma_instance(obj, vm, NULL);
14841486
if (IS_ERR(vma)) {
@@ -1531,8 +1533,10 @@ static int igt_ppgtt_pin_update(void *arg)
15311533
}
15321534

15331535
obj = i915_gem_object_create_internal(dev_priv, PAGE_SIZE);
1534-
if (IS_ERR(obj))
1535-
return PTR_ERR(obj);
1536+
if (IS_ERR(obj)) {
1537+
err = PTR_ERR(obj);
1538+
goto out_vm;
1539+
}
15361540

15371541
vma = i915_vma_instance(obj, vm, NULL);
15381542
if (IS_ERR(vma)) {

0 commit comments

Comments
 (0)