From: Colin King <colin.king@canonical.com>
To: Len Brown <len.brown@intel.com>
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] tools/power x86_energy_perf_policy: fix resource leak on file descriptor
Date: Wed, 17 May 2017 13:51:56 +0100 [thread overview]
Message-ID: <20170517125156.10977-1-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
Function get_pkg_num is leaking an open file, fix this with a fclose().
Detected with static analysis by cppcheck:
[tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c:1115]:
(error) Resource leak: fp
Fixes: 4beec1d7519691 ("tools/power x86_energy_perf_policy: support HWP.EPP")
Signed-off-by: Colin Ian King <colin.king@canonical.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 65bbe627a425..26a5b5265290 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
@@ -1110,6 +1110,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.11.0
next reply other threads:[~2017-05-17 12:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-17 12:51 Colin King [this message]
2017-05-31 17:24 ` Brown, Len
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=20170517125156.10977-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=kernel-janitors@vger.kernel.org \
--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®