[PATCH] tools/power/acpi: close file only if it is open

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Colin Ian King <colin.king@xxxxxxxxxxxxx>

the logic on the test for a valid fd to close is incorrect and
the current code will close -ve fd's which is not was intended.
Since the only path to the exit label is on a failed open, we
may as well just close fd if it has been opened successfully
before the exit label and also remove the valid fd check.

Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
---
 tools/power/acpi/tools/acpidbg/acpidbg.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/power/acpi/tools/acpidbg/acpidbg.c b/tools/power/acpi/tools/acpidbg/acpidbg.c
index d070fcc..38ccac9 100644
--- a/tools/power/acpi/tools/acpidbg/acpidbg.c
+++ b/tools/power/acpi/tools/acpidbg/acpidbg.c
@@ -429,9 +429,8 @@ int main(int argc, char **argv)
 		acpi_aml_flush(fd);
 	acpi_aml_loop(fd);
 
+	close(fd);
 exit:
-	if (fd < 0)
-		close(fd);
 	if (acpi_aml_batch_cmd)
 		free(acpi_aml_batch_cmd);
 	return ret;
-- 
2.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux