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 <[email protected]>
> ---
> 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,