Skip to content

Commit c52dcf4

Browse files
Rex Zhualexdeucher
authored andcommitted
drm/amd/pp: Avoid divide-by-zero in fan_ctrl_set_fan_speed_rpm
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 <[email protected]> Signed-off-by: Rex Zhu <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent b3ca0f3 commit c52dcf4

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ int smu7_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed)
260260
if (hwmgr->thermal_controller.fanInfo.bNoFan ||
261261
(hwmgr->thermal_controller.fanInfo.
262262
ucTachometerPulsesPerRevolution == 0) ||
263+
speed == 0 ||
263264
(speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) ||
264265
(speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM))
265266
return 0;

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ int vega10_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed)
312312
int result = 0;
313313

314314
if (hwmgr->thermal_controller.fanInfo.bNoFan ||
315+
speed == 0 ||
315316
(speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) ||
316317
(speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM))
317318
return -1;

0 commit comments

Comments
 (0)