[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220430135925.1657374-1-trix@redhat.com>
Date: Sat, 30 Apr 2022 09:59:25 -0400
From: Tom Rix <trix@...hat.com>
To: len.brown@...el.com
Cc: linux-kernel@...r.kernel.org, Tom Rix <trix@...hat.com>
Subject: [PATCH] tools/power x86_energy_perf_policy: close opened file
The cppcheck reports this issue
x86_energy_perf_policy.c:1244]: (error) Resource leak: fp
When a file is opened with fopen it should be closed with fclose.
So close it.
Fixes: 4beec1d75196 ("tools/power x86_energy_perf_policy: support HWP.EPP")
Signed-off-by: Tom Rix <trix@...hat.com>
---
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c b/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
index 5fd9e594079c..0ed9ae66236d 100644
--- a/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
+++ b/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
@@ -1239,6 +1239,7 @@ unsigned int get_pkg_num(int cpu)
fp = fopen_or_die(pathname, "r");
retval = fscanf(fp, "%d\n", &pkg);
+ fclose(fp);
if (retval != 1)
errx(1, "%s: failed to parse", pathname);
return pkg;
--
2.27.0
Powered by blists - more mailing lists