]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
tools/power turbostat: fix leak of file descriptor on error return path
authorColin Ian King <colin.king@canonical.com>
Mon, 8 Apr 2019 09:00:44 +0000 (10:00 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 21 Sep 2019 05:18:43 +0000 (07:18 +0200)
[ Upstream commit 15423b958f33132152e209e98df0dedc7a78f22c ]

Currently the error return path does not close the file fp and leaks
a file descriptor. Fix this by closing the file.

Fixes: 5ea7647b333f ("tools/power turbostat: Warn on bad ACPI LPIT data")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/power/x86/turbostat/turbostat.c

index 1cd28ebf8443be02d58199e4d5364b9610f52218..efc8d07364c61a65fec20b3089b0e3007dc78311 100644 (file)
@@ -2938,6 +2938,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);