cpukit/libblock: Close all valid FDs

This is intended to close any valid FDs that were opened, but 0 is also
a valid FD. This change ensures that a FD of 0 is also closed properly.

Coverity CID 1467408 (original)

Coverity CID 1616151 (followup)

off_by_one: Testing whether handle fd is strictly greater than zero is
suspicious. fd leaks when it is zero.
This commit is contained in:
Kinsey Moore
2024-08-12 12:52:36 -05:00
parent d81bf04501
commit 73918bc788

View File

@@ -213,7 +213,7 @@ cleanup:
* but fd may be -1. Coverity flagged passing a bad value to close(). * but fd may be -1. Coverity flagged passing a bad value to close().
*/ */
free( logical_disk_name); free( logical_disk_name);
if (fd > 0) { if (fd >= 0) {
close( fd); close( fd);
} }