Skip to content

Commit 8c28def

Browse files
committed
Fan: fix code review issue
When pwmMaxValue <= pwmMinValue (due to misconfiguration), the function returns without updating the fan speed, leaving it at its previous state. This could cause overheating if the fan isn't already running at an appropriate speed.
1 parent a33de5d commit 8c28def

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

usermods/PWM_fan/PWM_fan.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,10 @@ class PWMFanUsermod : public Usermod {
169169
int pwmMinValue = minPWMValuePct * _pwmMaxValue / 100;
170170
int pwmMaxValue = maxPWMValuePct * _pwmMaxValue / 100;
171171

172-
if (pwmMaxValue <= pwmMinValue) return;
172+
if (pwmMaxValue <= pwmMinValue) {
173+
updateFanSpeed(pwmMaxValue); // fail safe: run at max speed
174+
return;
175+
}
173176

174177
int pwmRange = pwmMaxValue - pwmMinValue;
175178

0 commit comments

Comments
 (0)