[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdmFGVPddi98yt22i+U+3aow+dwhxKgdJ45h3n1i-n3bzw@mail.gmail.com>
Date: Tue, 18 Apr 2023 13:48:17 -0700
From: Nick Desaulniers <ndesaulniers@...gle.com>
To: Jeffrey Hugo <quic_jhugo@...cinc.com>
Cc: Tom Rix <trix@...hat.com>, ogabbay@...nel.org, nathan@...nel.org,
jacek.lawrynowicz@...ux.intel.com, quic_carlv@...cinc.com,
stanislaw.gruszka@...ux.intel.com, quic_pkanojiy@...cinc.com,
linux-arm-msm@...r.kernel.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, llvm@...ts.linux.dev
Subject: Re: [PATCH] accel/qaic: initialize ret variable to 0
On Tue, Apr 18, 2023 at 1:46 PM Jeffrey Hugo <quic_jhugo@...cinc.com> wrote:
>
> On 4/18/2023 1:20 PM, Tom Rix wrote:
> > clang static analysis reports
> > drivers/accel/qaic/qaic_data.c:610:2: warning: Undefined or garbage
> > value returned to caller [core.uninitialized.UndefReturn]
> > return ret;
> > ^~~~~~~~~~
> >
> > The ret variable is only set some of the time but is always returned.
> > So initialize ret to 0.
>
> This does not appear to be entirely accurate to me.
>
> Do you know what analysis Clang is doing? Is it limited to the function
> itself?
>
> remap_pfn_range, which initializes ret, will always run at-least once.
What happens if the loop body is never executed, say if `bo->sgt->sgl` is NULL?
>
> Feels more accurate to say that Clang cannot detect that ret will be
> initialized, and we want to quiet the warning from the false positive.
>
> > Fixes: ff13be830333 ("accel/qaic: Add datapath")
> > Signed-off-by: Tom Rix <trix@...hat.com>
> > ---
> > drivers/accel/qaic/qaic_data.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/accel/qaic/qaic_data.c b/drivers/accel/qaic/qaic_data.c
> > index c0a574cd1b35..b46a16fb3080 100644
> > --- a/drivers/accel/qaic/qaic_data.c
> > +++ b/drivers/accel/qaic/qaic_data.c
> > @@ -591,7 +591,7 @@ static int qaic_gem_object_mmap(struct drm_gem_object *obj, struct vm_area_struc
> > struct qaic_bo *bo = to_qaic_bo(obj);
> > unsigned long offset = 0;
> > struct scatterlist *sg;
> > - int ret;
> > + int ret = 0;
> >
> > if (obj->import_attach)
> > return -EINVAL;
>
--
Thanks,
~Nick Desaulniers
Powered by blists - more mailing lists