Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1654481 > unrolled thread
| Started by | "Brown, Len" <len.brown@intel.com> |
|---|---|
| First post | 2017-05-31 19:30 +0200 |
| Last post | 2017-05-31 19:30 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
RE: [PATCH] tools/power x86_energy_perf_policy: fix resource leak on file descriptor "Brown, Len" <len.brown@intel.com> - 2017-05-31 19:30 +0200
| From | "Brown, Len" <len.brown@intel.com> |
|---|---|
| Date | 2017-05-31 19:30 +0200 |
| Subject | RE: [PATCH] tools/power x86_energy_perf_policy: fix resource leak on file descriptor |
| Message-ID | <tNfBw-7MH-13@gated-at.bofh.it> |
Acked-by: Len Brown <len.brown@intel.com>
-----Original Message-----
From: Colin King [mailto:colin.king@canonical.com]
Sent: Wednesday, May 17, 2017 8:52 AM
To: Brown, Len <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
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
Back to top | Article view | linux.kernel
csiph-web