From: "Christian König" <christian.koenig@amd.com>
To: Samasth Norway Ananda <samasth.norway.ananda@oracle.com>,
alexander.deucher@amd.com, amd-gfx@lists.freedesktop.org,
pierre-eric.pelloux-prayer@amd.com
Subject: Re: [PATCH] drm/amdgpu: fix uninitialized variable in amdgpu_fill_buffer()
Date: Thu, 5 Feb 2026 10:49:30 +0100 [thread overview]
Message-ID: <7ea6af25-e3f0-4d64-aec1-cfc1b7e5182b@amd.com> (raw)
In-Reply-To: <20260205021617.1279195-1-samasth.norway.ananda@oracle.com>
On 2/5/26 03:16, Samasth Norway Ananda wrote:
> Initialize 'r' to 0 so the function does not return an uninitialized
> value when the while loop body is never entered. Current callers always
> supply non-zero sized BOs so the loop always executes, but the function
> itself does not enforce this and static analysis tools flag the
> potential use.
>
> Fixes: 22f7cc752408 ("drm/amdgpu: restructure amdgpu_fill_buffer v2")
> Signed-off-by: Samasth Norway Ananda <samasth.norway.ananda@oracle.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 15d561e3d87f..44524eb2f74f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -2564,7 +2564,7 @@ int amdgpu_fill_buffer(struct amdgpu_ttm_buffer_entity *entity,
> struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
> struct dma_fence *fence = NULL;
> struct amdgpu_res_cursor dst;
> - int r;
> + int r = 0;
We usually avoid initializing return variables exactly for the reason that the compiler then can point out code paths missing to set it. So please just initialize it directly before the loop.
This is also not a real issue because the loop is always taken, e.g. zero dst.remaining is not possible, but the compiler or analyzing tool can't know that. So maybe drop the Fixes tag, no real reason to backport this except for cleanup and silencing the warning.
Regards,
Christian.
>
> if (!adev->mman.buffer_funcs_enabled) {
> dev_err(adev->dev,
prev parent reply other threads:[~2026-02-05 9:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-05 2:16 [PATCH] drm/amdgpu: fix uninitialized variable in amdgpu_fill_buffer() Samasth Norway Ananda
2026-02-05 9:49 ` Christian König [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=7ea6af25-e3f0-4d64-aec1-cfc1b7e5182b@amd.com \
--to=christian.koenig@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=pierre-eric.pelloux-prayer@amd.com \
--cc=samasth.norway.ananda@oracle.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