Skip to content

Commit 0638c98

Browse files
Vannoonnooalexdeucher
authored andcommitted
drm/amd/pm: Prevent divide by zero
divide error: 0000 [#1] SMP PTI CPU: 3 PID: 78925 Comm: tee Not tainted 5.15.50-1-lts #1 Hardware name: MSI MS-7A59/Z270 SLI PLUS (MS-7A59), BIOS 1.90 01/30/2018 RIP: 0010:smu_v11_0_set_fan_speed_rpm+0x11/0x110 [amdgpu] Speed is user-configurable through a file. I accidentally set it to zero, and the driver crashed. Reviewed-by: Evan Quan <[email protected]> Reviewed-by: André Almeida <[email protected]> Signed-off-by: Yefim Barashkin <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected]
1 parent add61d3 commit 0638c98

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,8 @@ int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu,
12281228
uint32_t crystal_clock_freq = 2500;
12291229
uint32_t tach_period;
12301230

1231+
if (speed == 0)
1232+
return -EINVAL;
12311233
/*
12321234
* To prevent from possible overheat, some ASICs may have requirement
12331235
* for minimum fan speed:

0 commit comments

Comments
 (0)