From 70bb72667889a2d6f250437e5db247eb111ca1aa Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Wed, 29 Mar 2017 17:04:55 +0100 Subject: [PATCH] dmfilemapd: always close check file descriptor (coverity) The daemon opens a new file descriptor from fm->path when checking for an unlinked file with mode=inode. Ensure that it is always closed even if the same file test fails. --- daemons/dmfilemapd/dmfilemapd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/daemons/dmfilemapd/dmfilemapd.c b/daemons/dmfilemapd/dmfilemapd.c index 0cb0ad713..3fd76b761 100644 --- a/daemons/dmfilemapd/dmfilemapd.c +++ b/daemons/dmfilemapd/dmfilemapd.c @@ -566,12 +566,14 @@ static int _filemap_monitor_check_file_unlinked(struct filemap_monitor *fm) if ((fd = open(fm->path, O_RDONLY)) < 0) goto check_unlinked; - if ((same = _filemap_monitor_check_same_file(fm->fd, fd)) < 0) - return 0; + same = _filemap_monitor_check_same_file(fm->fd, fd); if (close(fd)) log_error("Error closing fd %d", fd); + if (same < 0) + return 0; + if (same) return 1; -- 2.43.5