drm/amd/pp: Avoid divide-by-zero in fan_ctrl_set_fan_speed_rpm
authorRex Zhu <Rex.Zhu@amd.com>
Thu, 20 Sep 2018 03:50:26 +0000 (11:50 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 9 Oct 2018 22:00:25 +0000 (17:00 -0500)
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>
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c

index eef086c..5bdc0df 100644 (file)
@@ -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;
index 538de6c..3f807d6 100644 (file)
@@ -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;