If dm_get_opencount() fails, open_count will be negative, which means mpath_in_use() will never fail. However, dm_flush_map__() will eventually fail. There are multiple callers of dm_get_opencount() that run when trying to remove a device. All the others treat a failed call as if the device was in use, including one that will later be called directly on this device. So save ourselves the work, and exit early Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx> --- libmultipath/devmapper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 751b45d8..3667c51b 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -961,6 +961,11 @@ int mpath_in_use(const char *name) { int open_count = dm_get_opencount(name); + if (open_count < 0) { + condlog(0, "%s: %s: failed to get open count, assuming in use", + __func__, name); + return 1; + } if (open_count) { int part_count = 0; -- 2.46.2