Check if DM create device failed in an early phase.

This happens when concurrent creation of DM devices meets
in the very early state (no device node exists but creation fails).

Return -ENODEV here instead of -EINVAL.

(Should "fix" random verity concurrent test failure.)
This commit is contained in:
Milan Broz
2021-09-21 15:54:07 +02:00
parent a76310b53f
commit 10b1d6493e

View File

@@ -1346,12 +1346,6 @@ err:
return r;
}
static bool dm_device_exists(struct crypt_device *cd, const char *name)
{
int r = dm_status_device(cd, name);
return (r >= 0 || r == -EEXIST);
}
static int _dm_create_device(struct crypt_device *cd, const char *name, const char *type,
struct crypt_dm_active_device *dmd)
{
@@ -1402,8 +1396,11 @@ static int _dm_create_device(struct crypt_device *cd, const char *name, const ch
goto out;
if (!dm_task_run(dmt)) {
if (dm_device_exists(cd, name))
r = dm_status_device(cd, name);;
if (r >= 0)
r = -EEXIST;
if (r != -EEXIST && r != -ENODEV)
r = -EINVAL;
goto out;
}