From: Lv Zheng Date: Thu, 24 Mar 2016 05:01:28 +0000 (+0800) Subject: tools/power/acpi: close file only if it is open X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=60438d9a1ef4176d79739efadee122afe92904b8;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git tools/power/acpi: close file only if it is open The logic on the test for a valid fd to close is incorrect. This was just a mistake and was pointed out by Colin Ian King. Link: https://patchwork.kernel.org/patch/8620201/ Original-by: Colin Ian King Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki --- diff --git a/tools/power/acpi/tools/acpidbg/acpidbg.c b/tools/power/acpi/tools/acpidbg/acpidbg.c index d070fccdba6d..a88ac45b7756 100644 --- a/tools/power/acpi/tools/acpidbg/acpidbg.c +++ b/tools/power/acpi/tools/acpidbg/acpidbg.c @@ -375,7 +375,7 @@ void usage(FILE *file, char *progname) int main(int argc, char **argv) { - int fd = 0; + int fd = -1; int ch; int len; int ret = EXIT_SUCCESS; @@ -430,7 +430,7 @@ int main(int argc, char **argv) acpi_aml_loop(fd); exit: - if (fd < 0) + if (fd >= 0) close(fd); if (acpi_aml_batch_cmd) free(acpi_aml_batch_cmd);