From: Felix Kuehling <felix.kuehling@amd.com>
To: trix@redhat.com, alexander.deucher@amd.com,
christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@linux.ie,
daniel@ffwll.ch, nathan@kernel.org, ndesaulniers@google.com,
rajneesh.bhardwaj@amd.com, david.yatsin@amd.com
Cc: llvm@lists.linux.dev, dri-devel@lists.freedesktop.org,
amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/amdkfd: fix loop error handling
Date: Thu, 10 Feb 2022 14:17:41 -0500 [thread overview]
Message-ID: <d5007997-abec-0a1e-48c6-85485090ccd5@amd.com> (raw)
In-Reply-To: <20220210170418.2404807-1-trix@redhat.com>
Am 2022-02-10 um 12:04 schrieb trix@redhat.com:
> From: Tom Rix <trix@redhat.com>
>
> Clang static analysis reports this problem
> kfd_chardev.c:2594:16: warning: The expression is an uninitialized value.
> The computed value will also be garbage
> while (ret && i--) {
> ^~~
>
> i is a loop variable and this block unwinds a problem in the loop.
> When the error happens before the loop, this value is garbage.
> Move the initialization of i to its decalaration.
>
> Fixes: be072b06c739 ("drm/amdkfd: CRIU export BOs as prime dmabuf objects")
> Signed-off-by: Tom Rix <trix@redhat.com>
Thank you. I applied the patch to amd-staging-drm-next.
Regards,
Felix
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> index 636391c61cafb..4310ca07af130 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> @@ -2374,7 +2374,7 @@ static int criu_restore_bos(struct kfd_process *p,
> const bool criu_resume = true;
> bool flush_tlbs = false;
> int ret = 0, j = 0;
> - uint32_t i;
> + uint32_t i = 0;
>
> if (*priv_offset + (args->num_bos * sizeof(*bo_privs)) > max_priv_data_size)
> return -EINVAL;
> @@ -2410,7 +2410,7 @@ static int criu_restore_bos(struct kfd_process *p,
> *priv_offset += args->num_bos * sizeof(*bo_privs);
>
> /* Create and map new BOs */
> - for (i = 0; i < args->num_bos; i++) {
> + for (; i < args->num_bos; i++) {
> struct kfd_criu_bo_bucket *bo_bucket;
> struct kfd_criu_bo_priv_data *bo_priv;
> struct kfd_dev *dev;
prev parent reply other threads:[~2022-02-10 19:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-10 17:04 [PATCH] drm/amdkfd: fix loop error handling trix
2022-02-10 19:17 ` Felix Kuehling [this message]
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=d5007997-abec-0a1e-48c6-85485090ccd5@amd.com \
--to=felix.kuehling@amd.com \
--cc=Xinhui.Pan@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=david.yatsin@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=rajneesh.bhardwaj@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