From: Tom Rix <trix@redhat.com>
To: len.brown@intel.com
Cc: linux-kernel@vger.kernel.org, Tom Rix <trix@redhat.com>
Subject: [PATCH] tools/power x86_energy_perf_policy: close opened file
Date: Sat, 30 Apr 2022 09:59:25 -0400 [thread overview]
Message-ID: <20220430135925.1657374-1-trix@redhat.com> (raw)
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
reply other threads:[~2022-04-30 13:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220430135925.1657374-1-trix@redhat.com \
--to=trix@redhat.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®