lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <159059447457.30979.14504945135116433938@build.alporthouse.com>
Date:   Wed, 27 May 2020 16:47:54 +0100
From:   Chris Wilson <chris@...is-wilson.co.uk>
To:     Arnd Bergmann <arnd@...db.de>, Daniel Vetter <daniel@...ll.ch>,
        David Airlie <airlied@...ux.ie>,
        Jani Nikula <jani.nikula@...ux.intel.com>,
        Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>,
        Mika Kuoppala <mika.kuoppala@...ux.intel.com>,
        Rodrigo Vivi <rodrigo.vivi@...el.com>
Cc:     Andi Shyti <andi.shyti@...el.com>, Arnd Bergmann <arnd@...db.de>,
        Tvrtko Ursulin <tvrtko.ursulin@...el.com>,
        intel-gfx@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
        dri-devel@...ts.freedesktop.org,
        Matthew Auld <matthew.auld@...el.com>
Subject: Re: [PATCH 3/3] drm/i915/selftests: avoid bogus maybe-uninitialized warning

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@...db.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ