Skip to content

Commit

Permalink
drm/i915/gem: Fix oops in error handling code
Browse files Browse the repository at this point in the history
This code will Oops when it tries to i915_gem_object_free(obj) because
"obj" is an error pointer.

Fixes: 97d5539 ("drm/i915/region: convert object_create into object_init")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/YA6FkPn5S4ZDUGxq@mwanda
  • Loading branch information
Dan Carpenter authored and Chris Wilson committed Jan 25, 2021
1 parent 784f70e commit ad8db42
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions drivers/gpu/drm/i915/gem/i915_gem_stolen.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,22 +753,18 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *i915,
mutex_lock(&i915->mm.stolen_lock);
ret = drm_mm_reserve_node(&i915->mm.stolen, stolen);
mutex_unlock(&i915->mm.stolen_lock);
if (ret) {
obj = ERR_PTR(ret);
if (ret)
goto err_free;
}

obj = i915_gem_object_alloc();
if (!obj) {
obj = ERR_PTR(-ENOMEM);
ret = -ENOMEM;
goto err_stolen;
}

ret = __i915_gem_object_create_stolen(mem, obj, stolen);
if (ret) {
obj = ERR_PTR(ret);
if (ret)
goto err_object_free;
}

i915_gem_object_set_cache_coherency(obj, I915_CACHE_NONE);
return obj;
Expand All @@ -779,7 +775,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *i915,
i915_gem_stolen_remove_node(i915, stolen);
err_free:
kfree(stolen);
return obj;
return ERR_PTR(ret);
}

bool i915_gem_object_is_stolen(const struct drm_i915_gem_object *obj)
Expand Down

0 comments on commit ad8db42

Please sign in to comment.