intelcpusensor:always unlock peci fd in detectCPU
Currently, intelcpusensor can leave peci fd locked after detectCPU call.
This causes lock to fail for the next detectCPU call. It also can cause
kernel issues, when driver is unbound and application keeps the file open
(since peci_unlock is not called it keeps) - the kernel structures remain
in memory. Which means, that on application stop (during reboot or for
any reason) the kernel warnings/errors will appear.
Tested:
intelcpusensor journal log does not have below error message anymore
"intelcpusensor[31213]: PECI device failed to unlock."
Change-Id: Ib2e7682d5f9a25124aeb340cc5cdb5375b4d773d
Signed-off-by: Wang Xiaohua <wangxiaohua.1217@bytedance.com>
Signed-off-by: Zhikui Ren <zhikui.ren@intel.com>
diff --git a/src/IntelCPUSensorMain.cpp b/src/IntelCPUSensorMain.cpp
index daaba8f..757ebcf 100644
--- a/src/IntelCPUSensorMain.cpp
+++ b/src/IntelCPUSensorMain.cpp
@@ -592,10 +592,9 @@
{
std::cout << config.name << ", state: " << config.state << "\n";
}
+ peci_Unlock(peciFd);
}
- peci_Unlock(peciFd);
-
if (rescanDelaySeconds != 0U)
{
creationTimer.expires_after(std::chrono::seconds(rescanDelaySeconds));