Skip to contentSkip to conversation

drm/amdgpu: Initialize data to NULL in imu_v13_0_program_rlc_ram()

PATCH New Nathan Chancellor 1 participant 1 message Nov 28

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Initialize data to NULL in imu_v13_0_program_rlc_ram()

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")
---
 drivers/gpu/drm/amd/amdgpu/imu_v13_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/imu_v13_0.c +1 -1
index aea418be444a..eb18c7d3e120 100644
@@ -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,

Signature · 2 lines
Cheers,
Nathan