drm/i915/selftests: Avoid ERR_PTR dereference
authorChris Wilson <[email protected]>
Wed, 20 Jun 2018 11:24:41 +0000 (12:24 +0100)
committerChris Wilson <[email protected]>
Wed, 20 Jun 2018 12:12:22 +0000 (13:12 +0100)
Along the early error path for igt_switch_to_kernel_context we may try
to dereference an invalid error pointer. Instead, return early rather
than dump the GEM trace since we haven't yet emitted anything of
interest.

Reported-by: Dan Carpenter <[email protected]>
Fixes: 09a4c02e58c1 ("drm/i915: Look for an active kernel context before switching")
Signed-off-by: Chris Wilson <[email protected]>
Cc: Mika Kuoppala <[email protected]>
Cc: Joonas Lahtinen <[email protected]>
Reviewed-by: Joonas Lahtinen <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
drivers/gpu/drm/i915/selftests/i915_gem_context.c

index 836f1af8b833c0b32695d0e8bf5c2f92d4df7bdf..90c3c36173ba12800365818b15e13bbcc505d907 100644 (file)
@@ -519,8 +519,8 @@ static int igt_switch_to_kernel_context(void *arg)
        mutex_lock(&i915->drm.struct_mutex);
        ctx = kernel_context(i915);
        if (IS_ERR(ctx)) {
-               err = PTR_ERR(ctx);
-               goto out_unlock;
+               mutex_unlock(&i915->drm.struct_mutex);
+               return PTR_ERR(ctx);
        }
 
        /* First check idling each individual engine */