Message ID | 20200527140526.1458215-3-arnd@arndb.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/3] drm/i915/pmu: avoid an maybe-uninitialized warning | expand |
Quoting Arnd Bergmann (2020-05-27 15:05:10) > gcc has a problem following values through IS_ERR/PTR_ERR macros, > leading to a false-positive warning in allmodconfig, with any > compiler version: > > In file included from drivers/gpu/drm/i915/gt/intel_lrc.c:5892: > drivers/gpu/drm/i915/gt/selftest_lrc.c: In function 'create_gpr_client.isra.0': > drivers/gpu/drm/i915/gt/selftest_lrc.c:2902:23: error: 'rq' may be used uninitialized in this function [-Werror=maybe-uninitialized] > > This one is hard to avoid without impairing readability or adding a > bugus NULL pointer. > > Fixes: c92724de6db1 ("drm/i915/selftests: Try to detect rollback during batchbuffer preemption") > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > drivers/gpu/drm/i915/gt/selftest_lrc.c | 21 +++++++++++++-------- > 1 file changed, 13 insertions(+), 8 deletions(-) > > diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c > index 824f99c4cc7c..933c3f5adf0a 100644 > --- a/drivers/gpu/drm/i915/gt/selftest_lrc.c > +++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c > @@ -2908,23 +2908,25 @@ create_gpr_client(struct intel_engine_cs *engine, > > vma = i915_vma_instance(global->obj, ce->vm, NULL); > if (IS_ERR(vma)) { > - err = PTR_ERR(vma); > + rq = ERR_CAST(vma); > goto out_ce; > } > > err = i915_vma_pin(vma, 0, 0, PIN_USER); > - if (err) > + if (err) { > + rq = ERR_PTR(err); > goto out_ce; > + } > > batch = create_gpr_user(engine, vma, offset); > if (IS_ERR(batch)) { > - err = PTR_ERR(batch); > + rq = ERR_CAST(batch); > goto out_vma; > } > > rq = intel_context_create_request(ce); > if (IS_ERR(rq)) { > - err = PTR_ERR(rq); > + rq = ERR_CAST(rq); > goto out_batch; > } > > @@ -2946,17 +2948,20 @@ create_gpr_client(struct intel_engine_cs *engine, > i915_vma_unlock(batch); > i915_vma_unpin(batch); > > - if (!err) > + if (!err) { > i915_request_get(rq); > - i915_request_add(rq); > - > + i915_request_add(rq); > + } else { > + i915_request_add(rq); > + rq = ERR_PTR(err); > + } > out_batch: > i915_vma_put(batch); > out_vma: > i915_vma_unpin(vma); > out_ce: > intel_context_put(ce); > - return err ? ERR_PTR(err) : rq; > + return rq; Hmm, I've used this style a few times, so could do with some syntactic refinement. drivers/gpu/drm/i915/gem/i915_gem_userptr.c: return err ? ERR_PTR(err) : mm->mn; drivers/gpu/drm/i915/gt/selftest_hangcheck.c: return err ? ERR_PTR(err) : rq; drivers/gpu/drm/i915/gt/selftest_lrc.c: return err ? ERR_PTR(err) : rq; drivers/gpu/drm/i915/selftests/i915_gem_gtt.c: return err ? ERR_PTR(err) : rq; drivers/gpu/drm/i915/selftests/i915_request.c: return err ? ERR_PTR(err) : request; drivers/gpu/drm/i915/selftests/igt_spinner.c: return err ? ERR_PTR(err) : rq; -Chris
diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c index 824f99c4cc7c..933c3f5adf0a 100644 --- a/drivers/gpu/drm/i915/gt/selftest_lrc.c +++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c @@ -2908,23 +2908,25 @@ create_gpr_client(struct intel_engine_cs *engine, vma = i915_vma_instance(global->obj, ce->vm, NULL); if (IS_ERR(vma)) { - err = PTR_ERR(vma); + rq = ERR_CAST(vma); goto out_ce; } err = i915_vma_pin(vma, 0, 0, PIN_USER); - if (err) + if (err) { + rq = ERR_PTR(err); goto out_ce; + } batch = create_gpr_user(engine, vma, offset); if (IS_ERR(batch)) { - err = PTR_ERR(batch); + rq = ERR_CAST(batch); goto out_vma; } rq = intel_context_create_request(ce); if (IS_ERR(rq)) { - err = PTR_ERR(rq); + rq = ERR_CAST(rq); goto out_batch; } @@ -2946,17 +2948,20 @@ create_gpr_client(struct intel_engine_cs *engine, i915_vma_unlock(batch); i915_vma_unpin(batch); - if (!err) + if (!err) { i915_request_get(rq); - i915_request_add(rq); - + i915_request_add(rq); + } else { + i915_request_add(rq); + rq = ERR_PTR(err); + } out_batch: i915_vma_put(batch); out_vma: i915_vma_unpin(vma); out_ce: intel_context_put(ce); - return err ? ERR_PTR(err) : rq; + return rq; } static int preempt_user(struct intel_engine_cs *engine,
gcc has a problem following values through IS_ERR/PTR_ERR macros, leading to a false-positive warning in allmodconfig, with any compiler version: In file included from drivers/gpu/drm/i915/gt/intel_lrc.c:5892: drivers/gpu/drm/i915/gt/selftest_lrc.c: In function 'create_gpr_client.isra.0': drivers/gpu/drm/i915/gt/selftest_lrc.c:2902:23: error: 'rq' may be used uninitialized in this function [-Werror=maybe-uninitialized] This one is hard to avoid without impairing readability or adding a bugus NULL pointer. Fixes: c92724de6db1 ("drm/i915/selftests: Try to detect rollback during batchbuffer preemption") Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/gpu/drm/i915/gt/selftest_lrc.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)