--- src/libdevmapper.c +++ src/libdevmapper.c @@ -216,6 +216,10 @@ r = -EINVAL; if (!dm_task_get_info(dmt, &dmi)) goto out; + if (!dmi.exists) { + r = -ENODEV; + goto out; + } next = dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms);