Skip to content

Commit cf1976b

Browse files
icklerodrigovivi
authored andcommitted
drm/i915: Also drop vm.ref along error paths for vma construction
Not only do we need to release the vm.ref we acquired for the vma on the duplicate insert branch, but also for the normal error paths, so roll them all into one. Reported-by: Andi Shyti <[email protected]> Suggested-by: Andi Shyti <[email protected]> Fixes: 2850748 ("drm/i915: Pull i915_vma_pin under the vm->mutex") Signed-off-by: Chris Wilson <[email protected]> Cc: Andi Shyti <[email protected]> Cc: <[email protected]> # v5.5+ Reviewed-by: Andi Shyti <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 03fca66) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 4272367 commit cf1976b

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

drivers/gpu/drm/i915/i915_vma.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ vma_create(struct drm_i915_gem_object *obj,
104104
struct i915_address_space *vm,
105105
const struct i915_ggtt_view *view)
106106
{
107+
struct i915_vma *pos = ERR_PTR(-E2BIG);
107108
struct i915_vma *vma;
108109
struct rb_node *rb, **p;
109110

@@ -184,7 +185,6 @@ vma_create(struct drm_i915_gem_object *obj,
184185
rb = NULL;
185186
p = &obj->vma.tree.rb_node;
186187
while (*p) {
187-
struct i915_vma *pos;
188188
long cmp;
189189

190190
rb = *p;
@@ -196,17 +196,12 @@ vma_create(struct drm_i915_gem_object *obj,
196196
* and dispose of ours.
197197
*/
198198
cmp = i915_vma_compare(pos, vm, view);
199-
if (cmp == 0) {
200-
spin_unlock(&obj->vma.lock);
201-
i915_vm_put(vm);
202-
i915_vma_free(vma);
203-
return pos;
204-
}
205-
206199
if (cmp < 0)
207200
p = &rb->rb_right;
208-
else
201+
else if (cmp > 0)
209202
p = &rb->rb_left;
203+
else
204+
goto err_unlock;
210205
}
211206
rb_link_node(&vma->obj_node, rb, p);
212207
rb_insert_color(&vma->obj_node, &obj->vma.tree);
@@ -229,8 +224,9 @@ vma_create(struct drm_i915_gem_object *obj,
229224
err_unlock:
230225
spin_unlock(&obj->vma.lock);
231226
err_vma:
227+
i915_vm_put(vm);
232228
i915_vma_free(vma);
233-
return ERR_PTR(-E2BIG);
229+
return pos;
234230
}
235231

236232
static struct i915_vma *

0 commit comments

Comments
 (0)