summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2018-10-15 16:06:35 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2018-10-15 17:49:44 +0200
commitb1ff52ca146f58938c07f6c6855bc860453059e6 (patch)
treee7bd2277560aeb0e722440cd4a62e932296ccc9f
parent251366146727aac97af5de2eef855860d14910ca (diff)
downloadlvm2-b1ff52ca146f58938c07f6c6855bc860453059e6.tar.gz
cov: check dev_close_immediate
Function can report log_error() on fail path.
-rw-r--r--lib/device/dev-cache.c4
-rw-r--r--lib/device/dev-io.c6
-rw-r--r--tools/pvscan.c3
3 files changed, 8 insertions, 5 deletions
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 59e00ae9a..f83ccda48 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1302,8 +1302,8 @@ static int _check_for_open_devices(int close_immediate)
log_error("Device '%s' has been left open (%d remaining references).",
dev_name(dev), dev->open_count);
num_open++;
- if (close_immediate)
- dev_close_immediate(dev);
+ if (close_immediate && !dev_close_immediate(dev))
+ stack;
}
}
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index d4210a50b..a3643c4da 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -504,7 +504,8 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
/* dev_close_immediate will decrement this */
dev->open_count++;
- dev_close_immediate(dev);
+ if (!dev_close_immediate(dev))
+ return_0;
// FIXME: dev with DEV_ALLOCED is released
// but code is referencing it
}
@@ -585,7 +586,8 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
if (!(dev->flags & DEV_REGULAR) &&
((fstat(dev->fd, &buf) < 0) || (buf.st_rdev != dev->dev))) {
log_error("%s: fstat failed: Has device name changed?", name);
- dev_close_immediate(dev);
+ if (!dev_close_immediate(dev))
+ stack;
return 0;
}
diff --git a/tools/pvscan.c b/tools/pvscan.c
index fd75362f5..da630740f 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -284,7 +284,8 @@ static void _online_pvid_file_create(struct device *dev)
/* We don't care about syncing, these files are not even persistent. */
- close(fd);
+ if (close(fd))
+ log_sys_debug("close", path);
}
static int _online_pvid_file_exists(const char *pvid)