]> Git Repo - linux.git/commitdiff
drm/i915: Fix bug in user proto-context creation that leaked contexts
authorMatthew Brost <[email protected]>
Fri, 1 Oct 2021 15:58:25 +0000 (08:58 -0700)
committerTvrtko Ursulin <[email protected]>
Tue, 5 Oct 2021 09:19:39 +0000 (10:19 +0100)
Set number of engines before attempting to create contexts so the
function free_engines can clean up properly. Also check return of
alloc_engines for NULL.

v2:
 (Tvrtko)
  - Send as stand alone patch
 (John Harrison)
  - Check for alloc_engines returning NULL
v3:
 (Checkpatch / Tvrtko)
  - Remove braces around single line if statement

Cc: Jason Ekstrand <[email protected]>
Fixes: d4433c7600f7 ("drm/i915/gem: Use the proto-context to handle create parameters (v5)")
Reviewed-by: Tvrtko Ursulin <[email protected]>
Signed-off-by: Matthew Brost <[email protected]>
Cc: <[email protected]>
Signed-off-by: Tvrtko Ursulin <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
drivers/gpu/drm/i915/gem/i915_gem_context.c

index 51861a66547cfe8f8127628b8dcbebe3a832d111..74e33a4cdfe8c5fe68a645b45c66867d39d0f228 100644 (file)
@@ -941,6 +941,10 @@ static struct i915_gem_engines *user_engines(struct i915_gem_context *ctx,
        unsigned int n;
 
        e = alloc_engines(num_engines);
+       if (!e)
+               return ERR_PTR(-ENOMEM);
+       e->num_engines = num_engines;
+
        for (n = 0; n < num_engines; n++) {
                struct intel_context *ce;
                int ret;
@@ -974,7 +978,6 @@ static struct i915_gem_engines *user_engines(struct i915_gem_context *ctx,
                        goto free_engines;
                }
        }
-       e->num_engines = num_engines;
 
        return e;
 
This page took 0.064817 seconds and 4 git commands to generate.