From: "Mario Limonciello (AMD)" <[email protected]> Ensure adev->bios_scratch_reg_offset is non-zero before accessing scratch registers in amdgpu_atombios_scratch_regs_set_backlight_level() to avoid dereferencing unmapped MMIO offsets.
Signed-off-by: Mario Limonciello (AMD) <[email protected]> --- drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c index 27c0dc8f6137a..2d8c2ba04e670 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c @@ -1622,7 +1622,12 @@ void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev, void amdgpu_atombios_scratch_regs_set_backlight_level(struct amdgpu_device *adev, u32 backlight_level) { - u32 tmp = RREG32(adev->bios_scratch_reg_offset + 2); + u32 tmp; + + if (!adev->bios_scratch_reg_offset) + return; + + tmp = RREG32(adev->bios_scratch_reg_offset + 2); tmp &= ~ATOM_S2_CURRENT_BL_LEVEL_MASK; tmp |= (backlight_level << ATOM_S2_CURRENT_BL_LEVEL_SHIFT) & -- 2.43.0
