From: Alex Deucher <alexdeucher@gmail.com>
To: Luben Tuikov <luben.tuikov@amd.com>
Cc: Tom Rix <trix@redhat.com>,
"Deucher, Alexander" <alexander.deucher@amd.com>,
Christian Koenig <christian.koenig@amd.com>,
xinhui pan <Xinhui.Pan@amd.com>, Dave Airlie <airlied@linux.ie>,
Daniel Vetter <daniel@ffwll.ch>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Hawking Zhang <Hawking.Zhang@amd.com>,
John Clements <john.clements@amd.com>,
Tao Zhou <tao.zhou1@amd.com>,
"Chai, Thomas" <YiPeng.Chai@amd.com>,
"Stanley.Yang" <Stanley.Yang@amd.com>,
Dennis Li <Dennis.Li@amd.com>,
"Joshi, Mukul" <mukul.joshi@amd.com>,
Nirmoy Das <nirmoy.das@amd.com>,
llvm@lists.linux.dev,
Maling list - DRI developers <dri-devel@lists.freedesktop.org>,
amd-gfx list <amd-gfx@lists.freedesktop.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drm/amdgpu: fix amdgpu_ras_block_late_init error handler
Date: Thu, 17 Feb 2022 11:16:14 -0500 [thread overview]
Message-ID: <CADnq5_OGEURo76mzc4Sb2Jar465Xt4vkSMECDi5jCMH332zUAg@mail.gmail.com> (raw)
In-Reply-To: <51018469-3bab-e56d-7407-b16170b5d74c@amd.com>
Applied. Thanks!
Alex
On Thu, Feb 17, 2022 at 10:57 AM Luben Tuikov <luben.tuikov@amd.com> wrote:
>
> Thanks for catching this.
>
> Reviewed-by: Luben Tuikov <luben.tuikov@amd.com>
>
> Regards,
> Luben
>
> On 2022-02-17 10:38, trix@redhat.com wrote:
> > From: Tom Rix <trix@redhat.com>
> >
> > Clang build fails with
> > amdgpu_ras.c:2416:7: error: variable 'ras_obj' is used uninitialized
> > whenever 'if' condition is true
> > if (adev->in_suspend || amdgpu_in_reset(adev)) {
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > amdgpu_ras.c:2453:6: note: uninitialized use occurs here
> > if (ras_obj->ras_cb)
> > ^~~~~~~
> >
> > There is a logic error in the error handler's labels.
> > ex/ The sysfs: is the last goto label in the normal code but
> > is the middle of error handler. Rework the error handler.
> >
> > cleanup: is the first error, so it's handler should be last.
> >
> > interrupt: is the second error, it's handler is next. interrupt:
> > handles the failure of amdgpu_ras_interrupt_add_hander() by
> > calling amdgpu_ras_interrupt_remove_handler(). This is wrong,
> > remove() assumes the interrupt has been setup, not torn down by
> > add(). Change the goto label to cleanup.
> >
> > sysfs is the last error, it's handler should be first. sysfs:
> > handles the failure of amdgpu_ras_sysfs_create() by calling
> > amdgpu_ras_sysfs_remove(). But when the create() fails there
> > is nothing added so there is nothing to remove. This error
> > handler is not needed. Remove the error handler and change
> > goto label to interrupt.
> >
> > Fixes: b293e891b057 ("drm/amdgpu: add helper function to do common ras_late_init/fini (v3)")
> > Signed-off-by: Tom Rix <trix@redhat.com>
> > ---
> > drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 11 +++++------
> > 1 file changed, 5 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> > index b5cd21cb6e58..c5c8a666110f 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> > @@ -2432,12 +2432,12 @@ int amdgpu_ras_block_late_init(struct amdgpu_device *adev,
> > if (ras_obj->ras_cb) {
> > r = amdgpu_ras_interrupt_add_handler(adev, ras_block);
> > if (r)
> > - goto interrupt;
> > + goto cleanup;
> > }
> >
> > r = amdgpu_ras_sysfs_create(adev, ras_block);
> > if (r)
> > - goto sysfs;
> > + goto interrupt;
> >
> > /* Those are the cached values at init.
> > */
> > @@ -2447,12 +2447,11 @@ int amdgpu_ras_block_late_init(struct amdgpu_device *adev,
> > }
> >
> > return 0;
> > -cleanup:
> > - amdgpu_ras_sysfs_remove(adev, ras_block);
> > -sysfs:
> > +
> > +interrupt:
> > if (ras_obj->ras_cb)
> > amdgpu_ras_interrupt_remove_handler(adev, ras_block);
> > -interrupt:
> > +cleanup:
> > amdgpu_ras_feature_enable(adev, ras_block, 0);
> > return r;
> > }
>
next prev parent reply other threads:[~2022-02-17 16:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-17 15:38 [PATCH] drm/amdgpu: fix amdgpu_ras_block_late_init error handler trix
2022-02-17 15:57 ` Luben Tuikov
2022-02-17 16:16 ` Alex Deucher [this message]
2022-02-17 19:04 ` Nick Desaulniers
2022-02-17 19:06 ` Alex Deucher
2022-02-22 19:12 ` Kenny Ho
2022-03-01 20:14 ` Nick Desaulniers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CADnq5_OGEURo76mzc4Sb2Jar465Xt4vkSMECDi5jCMH332zUAg@mail.gmail.com \
--to=alexdeucher@gmail.com \
--cc=Dennis.Li@amd.com \
--cc=Hawking.Zhang@amd.com \
--cc=Stanley.Yang@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=YiPeng.Chai@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=john.clements@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=luben.tuikov@amd.com \
--cc=mukul.joshi@amd.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nirmoy.das@amd.com \
--cc=tao.zhou1@amd.com \
--cc=trix@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).