1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

dmfilemapd: always close link check file descriptor (coverity)

Similar to 40fb91a, but for the file descriptor opened using the
link path reported by /proc/<self>/fd/<fd>.

The daemon opens a new file descriptor from /proc/<self>/fd when
checking for an unlinked file with mode=inode. Ensure that it is
always closed even if the same file test fails.
This commit is contained in:
Bryn M. Reeves 2017-03-29 17:22:18 +01:00
parent 7db51a6bed
commit 8658bbe3ee

View File

@ -600,13 +600,15 @@ check_unlinked:
*/ */
if ((fd = open(link_buf, O_RDONLY)) < 0) if ((fd = open(link_buf, O_RDONLY)) < 0)
fm->deleted = 1; fm->deleted = 1;
else
if ((same = _filemap_monitor_check_same_file(fm->fd, fd)) < 0) same = _filemap_monitor_check_same_file(fm->fd, fd);
return 0;
if ((fd > 0) && close(fd)) if ((fd > 0) && close(fd))
log_error("Error closing fd %d", fd); log_error("Error closing fd %d", fd);
if (same < 0)
return 0;
/* Should not happen with normal /proc. */ /* Should not happen with normal /proc. */
if ((fd > 0) && !same) { if ((fd > 0) && !same) {
log_error("File descriptor mismatch: %d and %s (read from %s) " log_error("File descriptor mismatch: %d and %s (read from %s) "