diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index c004b6152..06a81a507 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.04 - ============================ + If _create_and_load_v4 fails part way through, revert the creation. dmeventd thread/fifo fixes. Add file & line to dm_strdup_aux(). Add setgeometry. diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c index 4cb49a682..02156ed9e 100644 --- a/libdm/ioctl/libdm-iface.c +++ b/libdm/ioctl/libdm-iface.c @@ -1383,7 +1383,7 @@ static int _create_and_load_v4(struct dm_task *dmt) task->tail = NULL; dm_task_destroy(task); if (!r) - return r; + goto revert; /* Use the original structure last so the info will be correct */ dmt->type = DM_DEVICE_RESUME; @@ -1392,6 +1392,17 @@ static int _create_and_load_v4(struct dm_task *dmt) r = dm_task_run(dmt); + if (r) + return r; + + revert: + dmt->type = DM_DEVICE_REMOVE; + dm_free(dmt->uuid); + dmt->uuid = NULL; + + if (!dm_task_run(dmt)) + log_error("Failed to revert device creation."); + return r; }