[PATCH] cpupower:Fix resource leaks in sysfs_get_enabled()
From: Hao Zeng
Date: Thu Apr 13 2023 - 00:46:22 EST
The sysfs_get_enabled() opened file processor not closed,
may cause a file handle leak.
Signed-off-by: Hao Zeng <zenghao@xxxxxxxxxx>
---
tools/power/cpupower/lib/powercap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/power/cpupower/lib/powercap.c b/tools/power/cpupower/lib/powercap.c
index 0ce29ee4c2e4..a39ee1c89679 100644
--- a/tools/power/cpupower/lib/powercap.c
+++ b/tools/power/cpupower/lib/powercap.c
@@ -51,7 +51,7 @@ static int sysfs_get_enabled(char *path, int *mode)
close(fd);
return -1;
}
-
+ close(fd);
if (yes_no == '1') {
*mode = 1;
return 0;
--
2.37.2
No virus found
Checked by Hillstone Network AntiVirus