#792169 thinkfan: Fails to set fan speed and exits when started at high temperature

Package:
thinkfan
Source:
thinkfan
Description:
simple and lightweight fan control program
Submitter:
Matthijs Kooijman
Date:
2022-06-13 23:00:05 UTC
Severity:
important
Tags:
#792169#5
Date:
2015-07-12 11:16:36 UTC
From:
To:
Hi,

while modifying my configuration to be a bit more aggressive on high
temperatures, I found that thinkfan exited without changing the fan
level. When started with -n, it wrote:

  setfan_ibm: Error writing to /proc/acpi/ibm/fan: Invalid argument
  Cleaning up and resetting fan control.

I've marked this bug as important, since it causes the fan to revert to
automatic hardware / BIOS control when the temperature is high, which is
likely when you need the extra fanspeed from thinkfan the most. Feel
free to downgrade if you feel this is less of an issue then I think :-)

Adding a bit of debug information shows that it tried to write the
empty string, instead of a proper fan level. It turns out that, at the
top of the fancontrol() function, lvl_idx is initialized at the maximum
level, but the cur_lvl variable is not changed.

Normally, this is not a problem since based on the temperature, the
index is stepped down to the appropriate level and cur_lvl is updated.
However, if the highest level turns out to be appropriate, thinkfan
continues to write the fan level, without updating cur_lvl.

The fix is simple: Just run the set_fan macro to set cur_lvl too. This
also means that the level is immediately made effective, which prevents
having to wait for the watchdog timeout if the highest fanlevel is
appropriate (which would be the effect of just setting cur_lvl instead
of calling set_fan).
--- thinkfan.c.orig     2015-07-12 13:09:28.259263201 +0200
+++ thinkfan.c  2015-07-12 13:09:43.231401029 +0200
@@ -111,6 +111,7 @@

        // Set initial fan level...
        lvl_idx = config->num_limits - 1;
+       set_fan;

        for (i=0; i < num_temps; i++)
                if (temps[i] > tmax) tmax = temps[i];


Gr.

Matthijs

#792169#10
Date:
2022-04-13 14:52:49 UTC
From:
To:
Hi Matthijs!

Does this bug still affect you? There have been a lot of changes since
your bug report (switch from C to C++ amongst others). I was not able to
reproduce the error, however I don't have the exact same hardware.

Greetings,
Lee