diff mbox series

tools/power turbostat: fix file descriptor leaks

Message ID 20190408161240.GA30623@embeddedor (mailing list archive)
State Accepted
Delegated to: Len Brown
Headers show
Series tools/power turbostat: fix file descriptor leaks | expand

Commit Message

Gustavo A. R. Silva April 8, 2019, 4:12 p.m. UTC
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(+)

Comments

Prarit Bhargava April 8, 2019, 5:04 p.m. UTC | #1
On 4/8/19 12:12 PM, Gustavo A. R. Silva wrote:
> 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>

Reviewed-by: Prarit Bhargava <prarit@redhat.com>

P.

> ---
>  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);
>
Gustavo A. R. Silva April 22, 2019, 3:15 p.m. UTC | #2
Hi all,

Friendly ping:

Who can take this?

Thanks
--
Gustavo

On 4/8/19 12:04 PM, Prarit Bhargava wrote:
> 
> 
> On 4/8/19 12:12 PM, Gustavo A. R. Silva wrote:
>> 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>
> 
> Reviewed-by: Prarit Bhargava <prarit@redhat.com>
> 
> P.
> 
>> ---
>>  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);
>>
Rafael J. Wysocki April 23, 2019, 8:23 a.m. UTC | #3
On Mon, Apr 22, 2019 at 5:55 PM Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
>
> 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!
Gustavo A. R. Silva Aug. 26, 2019, 4:03 a.m. UTC | #4
Hi Rafael,

On 4/23/19 3:23 AM, Rafael J. Wysocki wrote:
> On Mon, Apr 22, 2019 at 5:55 PM Gustavo A. R. Silva
> <gustavo@embeddedor.com> wrote:
>>
>> 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
Rafael J. Wysocki Aug. 26, 2019, 7:55 a.m. UTC | #5
On Mon, Aug 26, 2019 at 6:25 AM Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
>
> Hi Rafael,
>
> On 4/23/19 3:23 AM, Rafael J. Wysocki wrote:
> > On Mon, Apr 22, 2019 at 5:55 PM Gustavo A. R. Silva
> > <gustavo@embeddedor.com> wrote:
> >>
> >> 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.

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!
Rafael J. Wysocki Aug. 26, 2019, 8:13 a.m. UTC | #6
On Mon, Aug 26, 2019 at 10:02 AM Artem Bityutskiy <dedekind1@gmail.com> wrote:
>
> On Mon, 2019-08-26 at 09:55 +0200, Rafael J. Wysocki wrote:
>
> 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.
>
>
>
> 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!
diff mbox series

Patch

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);