Skip to contentSkip to conversation

tools/power turbostat: fix file descriptor leaks

PATCH In review Gustavo A. R. Silva 3 participants 7 messages Apr 8, 2019 – Aug 26, 2019 1 message not in the archive Turbostat utility

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/power turbostat: fix file descriptor leaks

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")
---
 tools/power/x86/turbostat/turbostat.c | 2 ++
 1 file changed, 2 insertions(+)
tools/power/x86/turbostat/turbostat.c +2 -0
index c7727be9719f..78d9acba8e9b 100644
@@ -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);
Signature · 1 line
2.21.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · 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")

P.

Quoted 25 lines
---
 tools/power/x86/turbostat/turbostat.c | 2 ++
 1 file changed, 2 insertions(+)
tools/power/x86/turbostat/turbostat.c +2 -0
index c7727be9719f..78d9acba8e9b 100644
@@ -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 lore raw

Hi all,

Friendly ping:

Who can take this?

Thanks
--
Gustavo

Quoted 39 lines · Prarit Bhargava
Quoted 6 lines · 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")

P.

Quoted 25 lines
---
 tools/power/x86/turbostat/turbostat.c | 2 ++
 1 file changed, 2 insertions(+)
tools/power/x86/turbostat/turbostat.c +2 -0
index c7727be9719f..78d9acba8e9b 100644
@@ -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);
#3 lore raw
Quoted 6 lines · Gustavo A. R. Silva

Hi all,

Friendly ping:

Who can take this?

I've been waiting for Len to comment on this, let me talk to him offlist.

Thanks!

#4 lore raw

Hi Rafael,

Quoted 11 lines · Rafael J. Wysocki
Quoted 6 lines · Gustavo A. R. Silva

Hi all,

Friendly ping:

Who can take this?

I've been waiting for Len to comment on this, let me talk to him offlist.

I just noticed this hasn't been applied.

I wonder if you plan to apply it.

Thanks
--
Gustavo

#5 lore raw
Quoted 11 lines · Gustavo A. R. Silva

Hi Rafael,

Quoted 7 lines · Rafael J. Wysocki
Quoted 5 lines · Gustavo A. R. Silva

Hi all,

Friendly ping:

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Who can take this?

I've been waiting for Len to comment on this, let me talk to him offlist.

I just noticed this hasn't been applied.

I wonder if you plan to apply it.

Technically, Len Brown is the turbostat maintainer and I have been waiting for him to review the patch at least. Let me talk to Len.

Thanks!

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 5 lines · Artem Bityutskiy

On Mon, 2019-08-26 at 09:55 +0200, Rafael J. Wysocki wrote:

Technically, Len Brown is the turbostat maintainer and I have been

Quoted 8 lines

waiting for him to review the patch at least. Let me talk to Len.

Hi Rafael,

I also sent a couple of turbostat patches waiting for being acted upon, may be you could include them to the conversation too?

Yes, I will, thanks!