* [PATCH] tools/power x86_energy_perf_policy: close opened file
@ 2022-04-30 13:59 Tom Rix
0 siblings, 0 replies; only message in thread
From: Tom Rix @ 2022-04-30 13:59 UTC (permalink / raw)
To: len.brown; +Cc: linux-kernel, Tom Rix
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@redhat.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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-04-30 13:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-30 13:59 [PATCH] tools/power x86_energy_perf_policy: close opened file Tom Rix
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®