drm/radeon: implement bounds checking on thermal controller lookup
Subsystems (2)
PATCH 1/1 drm/radeon: implement bounds checking on thermal controller lookup
From: Alex Deucher <[email protected]>
Don't read past the end of the array if we encounter an unknown thermal controller.
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/radeon/radeon_atombios.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_atombios.c +9 -2
@@ -2009,7 +2009,8 @@ static int radeon_atombios_parse_power_table_1_3(struct radeon_device *rdev) power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);/* add the i2c bus for thermal/fan chip */ -if (power_info->info.ucOverdriveThermalController >0 ) { +if ((power_info->info.ucOverdriveThermalController >0 ) && + (power_info->info.ucOverdriveThermalController <ARRAY_SIZE (thermal_controller_names))) {DRM_INFO ("Possible %s thermal controller at 0x%02x\n" , thermal_controller_names[power_info->info.ucOverdriveThermalController], power_info->info.ucOverdriveControllerAddress >>1 );
@@ -2213,7 +2214,7 @@ static void radeon_atombios_add_pplib_thermal_controller(struct radeon_device *r (controller->ucType == ATOM_PP_THERMALCONTROLLER_EMC2103_WITH_INTERNAL)) {DRM_INFO ("Special thermal controller config\n" ); - } else { + } else if (controller->ucType < ARRAY_SIZE(pp_lib_thermal_controller_names)) { DRM_INFO("Possible %s thermal controller at 0x%02x %s fan control\n", pp_lib_thermal_controller_names[controller->ucType], controller->ucI2cAddress >> 1,
@@ -2228,6 +2229,12 @@ static void radeon_atombios_add_pplib_thermal_controller(struct radeon_device *rstrlcpy (info.type, name,sizeof (info.type));i2c_new_device (&rdev->pm.i2c_bus->adapter, &info); } + }else { +DRM_INFO ("Unknown thermal controller type %d at 0x%02x %s fan control\n" , + controller->ucType, + controller->ucI2cAddress >>1 , + (controller->ucFanParameters & +ATOM_PP_FANPARAMETERS_NOFAN ) ?"without" :"with" ); } } }
Signature · 1 line
1.7.7.5
Quoted 6 lines · On Don, 2012-08-30 at 13:32 -0400, [email protected] wrote:
From: Alex Deucher <[email protected]>
Don't read past the end of the array if we encounter an unknown thermal controller.
Signed-off-by Alex Deucher <[email protected]>
Reviewed-by Michel Dänzer <[email protected]>
Signature · 2 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Debian, X and DRI developer