Skip to content

Commit

Permalink
drm/amd/pp: Avoid divide-by-zero in fan_ctrl_set_fan_speed_rpm
Browse files Browse the repository at this point in the history
The minRPM speed maybe equal to zero. so need to check
input RPM not equal to 0, otherwise cause divide-by-zero driver crash.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
  • Loading branch information
Rex Zhu authored and Alex Deucher committed Oct 9, 2018
1 parent b3ca0f3 commit c52dcf4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ int smu7_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed)
if (hwmgr->thermal_controller.fanInfo.bNoFan ||
(hwmgr->thermal_controller.fanInfo.
ucTachometerPulsesPerRevolution == 0) ||
speed == 0 ||
(speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) ||
(speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM))
return 0;
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ int vega10_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed)
int result = 0;

if (hwmgr->thermal_controller.fanInfo.bNoFan ||
speed == 0 ||
(speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) ||
(speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM))
return -1;
Expand Down

0 comments on commit c52dcf4

Please sign in to comment.