summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2017-03-29 17:22:18 +0100
committerBryn M. Reeves <bmr@redhat.com>2017-03-29 18:34:11 +0100
commit8658bbe3eed38183554643f93f4c23718fd24827 (patch)
tree1f8d1568408beb4e0a4a7b63eb8ed4fe2044a408
parent7db51a6bed8704ec634b44b4c5bd1dc35fdae86b (diff)
downloadlvm2-8658bbe3eed38183554643f93f4c23718fd24827.tar.gz
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.
-rw-r--r--daemons/dmfilemapd/dmfilemapd.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/daemons/dmfilemapd/dmfilemapd.c b/daemons/dmfilemapd/dmfilemapd.c
index 6e25c5ced..0f3780be9 100644
--- a/daemons/dmfilemapd/dmfilemapd.c
+++ b/daemons/dmfilemapd/dmfilemapd.c
@@ -600,13 +600,15 @@ check_unlinked:
*/
if ((fd = open(link_buf, O_RDONLY)) < 0)
fm->deleted = 1;
-
- if ((same = _filemap_monitor_check_same_file(fm->fd, fd)) < 0)
- return 0;
+ else
+ same = _filemap_monitor_check_same_file(fm->fd, fd);
if ((fd > 0) && close(fd))
log_error("Error closing fd %d", fd);
+ if (same < 0)
+ return 0;
+
/* Should not happen with normal /proc. */
if ((fd > 0) && !same) {
log_error("File descriptor mismatch: %d and %s (read from %s) "