Skip to contentSkip to conversation

drm/i915/selftests: Teach igt_gpu_fill_dw() to take intel_context

bug report Dan Carpenter 2 participants 2 messages Aug 27, 2019

lore
Share & tools
lore
#0 lore raw

Hello Chris Wilson,

The patch 75b974a859e5: "drm/i915/selftests: Teach igt_gpu_fill_dw() to take intel_context" from Aug 24, 2019, leads to the following static checker warning:

	drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c:402 igt_ctx_exec()
	error: 'ce' dereferencing possible ERR_PTR()

drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
388 dw = 0;
389 while (!time_after(jiffies, end_time)) {
390 struct i915_gem_context *ctx;
391 struct intel_context *ce;
392
393 ctx = live_context(i915, file);
394 if (IS_ERR(ctx)) {
395 err = PTR_ERR(ctx);
396 goto out_unlock;
397 }
398

   399                          ce = i915_gem_context_get_engine(ctx, engine->legacy_idx);
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

New assignment. Smatch thinks it can be ERR_PTR(-EINVAL)

400
401 if (!obj) {

   402                                  obj = create_test_object(ce->vm, file, &objects);
                                                                 ^^^^^^

Dereference.

   403                                  if (IS_ERR(obj)) {
   404                                          err = PTR_ERR(obj);
   405                                          intel_context_put(ce);
   406                                          goto out_unlock;
   407                                  }
   408                          }
   409  
   410                          err = gpu_fill(ce, obj, dw);
   411                          intel_context_put(ce);
   412  
   413                          if (err) {
   414                                  pr_err("Failed to fill dword %lu [%lu/%lu] with gpu (%s) in ctx %u [full-ppgtt? %s], err=%d\n",
   415                                         ndwords, dw, max_dwords(obj),
   416                                         engine->name, ctx->hw_id,
   417                                         yesno(!!ctx->vm), err);
   418                                  goto out_unlock;
   419                          }

See also:

drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c:410 igt_ctx_exec() error: 'ce' dereferencing possible ERR_PTR() drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c:528 igt_shared_ctx_exec() error: 'ce' dereferencing possible ERR_PTR() drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c:534 igt_shared_ctx_exec() error: 'ce' dereferencing possible ERR_PTR()

regards,
dan carpenter
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#1 lore raw

Quoting Dan Carpenter (2019-08-27 10:40:16)

Quoted 23 lines

Hello Chris Wilson,

The patch 75b974a859e5: "drm/i915/selftests: Teach igt_gpu_fill_dw() to take intel_context" from Aug 24, 2019, leads to the following static checker warning:

drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c:402 igt_ctx_exec()
error: 'ce' dereferencing possible ERR_PTR()

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

   388                  dw = 0;
   389                  while (!time_after(jiffies, end_time)) {
   390                          struct i915_gem_context *ctx;
   391                          struct intel_context *ce;
   392  
   393                          ctx = live_context(i915, file);
   394                          if (IS_ERR(ctx)) {
   395                                  err = PTR_ERR(ctx);
   396                                  goto out_unlock;
   397                          }
   398  
   399                          ce = i915_gem_context_get_engine(ctx, engine->legacy_idx);
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 1 line

New assignment. Smatch thinks it can be ERR_PTR(-EINVAL)

It can't be from successful construction of the live_context().

GEM_BUG_ON(IS_ERR(ce)) I guess.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx