Commit 4ad3ea1c authored by Nathan Chancellor's avatar Nathan Chancellor Committed by Jani Nikula

drm/i915/selftests: Do not use import_obj uninitialized

Clang warns a couple of times:

drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c:63:6: warning:
variable 'import_obj' is used uninitialized whenever 'if' condition is
true [-Wsometimes-uninitialized]
        if (import != &obj->base) {
            ^~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c:80:22: note:
uninitialized use occurs here
        i915_gem_object_put(import_obj);
                            ^~~~~~~~~~
drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c:63:2: note: remove
the 'if' if its condition is always false
        if (import != &obj->base) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c:38:46: note:
initialize the variable 'import_obj' to silence this warning
        struct drm_i915_gem_object *obj, *import_obj;
                                                    ^
                                                     = NULL

Shuffle the import_obj initialization above these if statements so that
it is not used uninitialized.

Fixes: d7b2cb38 ("drm/i915/gem: Correct the locking and pin pattern for dma-buf (v8)")
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarThomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210824225427.2065517-2-nathan@kernel.org
(cherry picked from commit 4796054b)
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
parent 00598d5c
...@@ -59,13 +59,13 @@ static int igt_dmabuf_import_self(void *arg) ...@@ -59,13 +59,13 @@ static int igt_dmabuf_import_self(void *arg)
err = PTR_ERR(import); err = PTR_ERR(import);
goto out_dmabuf; goto out_dmabuf;
} }
import_obj = to_intel_bo(import);
if (import != &obj->base) { if (import != &obj->base) {
pr_err("i915_gem_prime_import created a new object!\n"); pr_err("i915_gem_prime_import created a new object!\n");
err = -EINVAL; err = -EINVAL;
goto out_import; goto out_import;
} }
import_obj = to_intel_bo(import);
i915_gem_object_lock(import_obj, NULL); i915_gem_object_lock(import_obj, NULL);
err = __i915_gem_object_get_pages(import_obj); err = __i915_gem_object_get_pages(import_obj);
...@@ -176,6 +176,7 @@ static int igt_dmabuf_import_same_driver(struct drm_i915_private *i915, ...@@ -176,6 +176,7 @@ static int igt_dmabuf_import_same_driver(struct drm_i915_private *i915,
err = PTR_ERR(import); err = PTR_ERR(import);
goto out_dmabuf; goto out_dmabuf;
} }
import_obj = to_intel_bo(import);
if (import == &obj->base) { if (import == &obj->base) {
pr_err("i915_gem_prime_import reused gem object!\n"); pr_err("i915_gem_prime_import reused gem object!\n");
...@@ -183,8 +184,6 @@ static int igt_dmabuf_import_same_driver(struct drm_i915_private *i915, ...@@ -183,8 +184,6 @@ static int igt_dmabuf_import_same_driver(struct drm_i915_private *i915,
goto out_import; goto out_import;
} }
import_obj = to_intel_bo(import);
i915_gem_object_lock(import_obj, NULL); i915_gem_object_lock(import_obj, NULL);
err = __i915_gem_object_get_pages(import_obj); err = __i915_gem_object_get_pages(import_obj);
if (err) { if (err) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment