Skip to content

Commit 4ad3ea1

Browse files
nathanchancejnikula
authored andcommitted
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: d7b2cb3 ("drm/i915/gem: Correct the locking and pin pattern for dma-buf (v8)") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Signed-off-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Jani Nikula <jani.nikula@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20210824225427.2065517-2-nathan@kernel.org (cherry picked from commit 4796054) Signed-off-by: Jani Nikula <jani.nikula@intel.com>
1 parent 00598d5 commit 4ad3ea1

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ static int igt_dmabuf_import_self(void *arg)
5959
err = PTR_ERR(import);
6060
goto out_dmabuf;
6161
}
62+
import_obj = to_intel_bo(import);
6263

6364
if (import != &obj->base) {
6465
pr_err("i915_gem_prime_import created a new object!\n");
6566
err = -EINVAL;
6667
goto out_import;
6768
}
68-
import_obj = to_intel_bo(import);
6969

7070
i915_gem_object_lock(import_obj, NULL);
7171
err = __i915_gem_object_get_pages(import_obj);
@@ -176,15 +176,14 @@ static int igt_dmabuf_import_same_driver(struct drm_i915_private *i915,
176176
err = PTR_ERR(import);
177177
goto out_dmabuf;
178178
}
179+
import_obj = to_intel_bo(import);
179180

180181
if (import == &obj->base) {
181182
pr_err("i915_gem_prime_import reused gem object!\n");
182183
err = -EINVAL;
183184
goto out_import;
184185
}
185186

186-
import_obj = to_intel_bo(import);
187-
188187
i915_gem_object_lock(import_obj, NULL);
189188
err = __i915_gem_object_get_pages(import_obj);
190189
if (err) {

0 commit comments

Comments
 (0)