Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Initialize data to NULL in imu_v13_0_program_rlc_ram()
@ 2026-11-28 16:25 Nathan Chancellor
  2026-11-30 16:58 ` Alex Deucher
  0 siblings, 1 reply; 4+ messages in thread
From: Nathan Chancellor @ 2026-11-28 16:25 UTC (permalink / raw)
  To: Alex Deucher, Christian König
  Cc: Hawking Zhang, Frank Min, Likun Gao, amd-gfx, dri-devel, llvm,
	Nathan Chancellor

Clang warns (or errors with CONFIG_WERROR=y / W=e):

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

It is not wrong that data is passed to program_imu_rlc_ram()
uninitialized but since this warning happens early in clang's frontend,
it cannot see program_imu_rlc_ram() is meber called due to r being
-EINVAL and even if it were, data would not be dereferenced because size
is 0, so it is never actually used uninitialized.

It is bad form to pass uninitialized values to functions even if they
are not used, so just initialize data to NULL to silence the warning, as
it will need to be properly set up when support for calling
program_imu_rlc_ram() is added.

Fixes: 9caddf5f7de7 ("drm/amdgpu: Add imu v13 ip block v2")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/gpu/drm/amd/amdgpu/imu_v13_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/imu_v13_0.c b/drivers/gpu/drm/amd/amdgpu/imu_v13_0.c
index aea418be444a..eb18c7d3e120 100644
--- a/drivers/gpu/drm/amd/amdgpu/imu_v13_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/imu_v13_0.c
@@ -253,7 +253,7 @@ static void program_imu_rlc_ram(struct amdgpu_device *adev,
 static void imu_v13_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: fc652f23f1c3c727e561ca66bafd58000208e3a9
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
change-id: 20261128-amdgpu-uninitialized-data-imu_v13_0-956b94f659dd

Best regards,
--  
Cheers,
Nathan


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

end of thread, other threads:[~2026-11-30 20:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 16:25 [PATCH] drm/amdgpu: Initialize data to NULL in imu_v13_0_program_rlc_ram() Nathan Chancellor
2026-11-30 16:58 ` Alex Deucher
2026-11-30 19:56   ` Nathan Chancellor
2026-11-30 20:03     ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox