llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Initialize data to NULL in imu_v12_0_program_rlc_ram()
@ 2025-07-15 23:50 Nathan Chancellor
  2025-07-18 13:58 ` Deucher, Alexander
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2025-07-15 23:50 UTC (permalink / raw)
  To: Alex Deucher, Christian König
  Cc: Likun Gao, Hawking Zhang, amd-gfx, dri-devel, llvm, patches,
	stable, Nathan Chancellor

After a recent change in clang to expose uninitialized warnings from
const variables and pointers [1], there is a warning in
imu_v12_0_program_rlc_ram() because data is passed uninitialized to
program_imu_rlc_ram():

  drivers/gpu/drm/amd/amdgpu/imu_v12_0.c:374:30: error: variable 'data' is uninitialized when used here [-Werror,-Wuninitialized]
    374 |                         program_imu_rlc_ram(adev, data, (const u32)size);
        |                                                   ^~~~

As this warning happens early in clang's frontend, it does not realize
that due to the assignment of r to -EINVAL, program_imu_rlc_ram() is
never actually called, and even if it were, data would not be
dereferenced because size is 0.

Just initialize data to NULL to silence the warning, as the commit that
added program_imu_rlc_ram() mentioned it would eventually be used over
the old method, at which point data can be properly initialized and
used.

Cc: stable@vger.kernel.org
Closes: https://github.com/ClangBuiltLinux/linux/issues/2107
Fixes: 56159fffaab5 ("drm/amdgpu: use new method to program rlc ram")
Link: https://github.com/llvm/llvm-project/commit/2464313eef01c5b1edf0eccf57a32cdee01472c7 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/gpu/drm/amd/amdgpu/imu_v12_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/imu_v12_0.c b/drivers/gpu/drm/amd/amdgpu/imu_v12_0.c
index df898dbb746e..8cb6b1854d24 100644
--- a/drivers/gpu/drm/amd/amdgpu/imu_v12_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/imu_v12_0.c
@@ -362,7 +362,7 @@ static void program_imu_rlc_ram(struct amdgpu_device *adev,
 static void imu_v12_0_program_rlc_ram(struct amdgpu_device *adev)
 {
 	u32 reg_data, size = 0;
-	const u32 *data;
+	const u32 *data = NULL;
 	int r = -EINVAL;
 
 	WREG32_SOC15(GC, 0, regGFX_IMU_RLC_RAM_INDEX, 0x2);

---
base-commit: fff8e0504499a929f26e2fb7cf7e2c9854e37b91
change-id: 20250715-drm-amdgpu-fix-const-uninit-warning-db61fe5d135a

Best regards,
--  
Nathan Chancellor <nathan@kernel.org>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH] drm/amdgpu: Initialize data to NULL in imu_v12_0_program_rlc_ram()
  2025-07-15 23:50 [PATCH] drm/amdgpu: Initialize data to NULL in imu_v12_0_program_rlc_ram() Nathan Chancellor
@ 2025-07-18 13:58 ` Deucher, Alexander
  0 siblings, 0 replies; 2+ messages in thread
From: Deucher, Alexander @ 2025-07-18 13:58 UTC (permalink / raw)
  To: Nathan Chancellor, Koenig, Christian
  Cc: Gao, Likun, Zhang, Hawking, amd-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org, llvm@lists.linux.dev,
	patches@lists.linux.dev, stable@vger.kernel.org

[Public]

> -----Original Message-----
> From: Nathan Chancellor <nathan@kernel.org>
> Sent: Tuesday, July 15, 2025 7:50 PM
> To: Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian
> <Christian.Koenig@amd.com>
> Cc: Gao, Likun <Likun.Gao@amd.com>; Zhang, Hawking
> <Hawking.Zhang@amd.com>; amd-gfx@lists.freedesktop.org; dri-
> devel@lists.freedesktop.org; llvm@lists.linux.dev; patches@lists.linux.dev;
> stable@vger.kernel.org; Nathan Chancellor <nathan@kernel.org>
> Subject: [PATCH] drm/amdgpu: Initialize data to NULL in
> imu_v12_0_program_rlc_ram()
>
> After a recent change in clang to expose uninitialized warnings from const variables
> and pointers [1], there is a warning in
> imu_v12_0_program_rlc_ram() because data is passed uninitialized to
> program_imu_rlc_ram():
>
>   drivers/gpu/drm/amd/amdgpu/imu_v12_0.c:374:30: error: variable 'data' is
> uninitialized when used here [-Werror,-Wuninitialized]
>     374 |                         program_imu_rlc_ram(adev, data, (const u32)size);
>         |                                                   ^~~~
>
> As this warning happens early in clang's frontend, it does not realize that due to the
> assignment of r to -EINVAL, program_imu_rlc_ram() is never actually called, and
> even if it were, data would not be dereferenced because size is 0.
>
> Just initialize data to NULL to silence the warning, as the commit that added
> program_imu_rlc_ram() mentioned it would eventually be used over the old method,
> at which point data can be properly initialized and used.
>
> Cc: stable@vger.kernel.org
> Closes: https://github.com/ClangBuiltLinux/linux/issues/2107
> Fixes: 56159fffaab5 ("drm/amdgpu: use new method to program rlc ram")
> Link: https://github.com/llvm/llvm-
> project/commit/2464313eef01c5b1edf0eccf57a32cdee01472c7 [1]
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Applied.  Thanks!

Alex

> ---
>  drivers/gpu/drm/amd/amdgpu/imu_v12_0.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/imu_v12_0.c
> b/drivers/gpu/drm/amd/amdgpu/imu_v12_0.c
> index df898dbb746e..8cb6b1854d24 100644
> --- a/drivers/gpu/drm/amd/amdgpu/imu_v12_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/imu_v12_0.c
> @@ -362,7 +362,7 @@ static void program_imu_rlc_ram(struct amdgpu_device
> *adev,  static void imu_v12_0_program_rlc_ram(struct amdgpu_device *adev)  {
>       u32 reg_data, size = 0;
> -     const u32 *data;
> +     const u32 *data = NULL;
>       int r = -EINVAL;
>
>       WREG32_SOC15(GC, 0, regGFX_IMU_RLC_RAM_INDEX, 0x2);
>
> ---
> base-commit: fff8e0504499a929f26e2fb7cf7e2c9854e37b91
> change-id: 20250715-drm-amdgpu-fix-const-uninit-warning-db61fe5d135a
>
> Best regards,
> --
> Nathan Chancellor <nathan@kernel.org>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-07-18 13:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-15 23:50 [PATCH] drm/amdgpu: Initialize data to NULL in imu_v12_0_program_rlc_ram() Nathan Chancellor
2025-07-18 13:58 ` Deucher, Alexander

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).