public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools/power turbostat: fix file descriptor leaks
@ 2019-04-08 16:12 Gustavo A. R. Silva
  2019-04-08 17:04 ` Prarit Bhargava
  0 siblings, 1 reply; 7+ messages in thread
From: Gustavo A. R. Silva @ 2019-04-08 16:12 UTC (permalink / raw)
  To: Len Brown, Prarit Bhargava; +Cc: linux-pm, linux-kernel, Gustavo A. R. Silva

Fix file descriptor leaks by closing fp before return.

Addresses-Coverity-ID: 1444591 ("Resource leak")
Addresses-Coverity-ID: 1444592 ("Resource leak")
Fixes: 5ea7647b333f ("tools/power turbostat: Warn on bad ACPI LPIT data")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 tools/power/x86/turbostat/turbostat.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index c7727be9719f..78d9acba8e9b 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -2924,6 +2924,7 @@ int snapshot_cpu_lpi_us(void)
 	if (retval != 1) {
 		fprintf(stderr, "Disabling Low Power Idle CPU output\n");
 		BIC_NOT_PRESENT(BIC_CPU_LPI);
+		fclose(fp);
 		return -1;
 	}
 
@@ -2950,6 +2951,7 @@ int snapshot_sys_lpi_us(void)
 	if (retval != 1) {
 		fprintf(stderr, "Disabling Low Power Idle System output\n");
 		BIC_NOT_PRESENT(BIC_SYS_LPI);
+		fclose(fp);
 		return -1;
 	}
 	fclose(fp);
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-08-26  8:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-08 16:12 [PATCH] tools/power turbostat: fix file descriptor leaks Gustavo A. R. Silva
2019-04-08 17:04 ` Prarit Bhargava
2019-04-22 15:15   ` Gustavo A. R. Silva
2019-04-23  8:23     ` Rafael J. Wysocki
2019-08-26  4:03       ` Gustavo A. R. Silva
2019-08-26  7:55         ` Rafael J. Wysocki
     [not found]           ` <841150bdcbd88a00a30a7ba86272918263959699.camel@gmail.com>
2019-08-26  8:13             ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox