From 887c9834bba86a5af551a0a0d56a327e4eb90076 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 20 Oct 2011 10:38:04 +0000 Subject: [PATCH] Cleanup backtraces Make sure stacks are at the right places when something goes wrong here. --- WHATS_NEW_DM | 1 + libdm/ioctl/libdm-iface.c | 50 ++++++++++++++++++--------------------- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 0c0d93210..67d19fa60 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.68 - ================================== + Cleanup backtraces for _create_and_load_v4(). Fix alignment warning in bitcount calculation for raid segment. Allocate dm_tree structure from dm_tree pool. Update debug logging for _resume_node. diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c index 737180f75..707d4409b 100644 --- a/libdm/ioctl/libdm-iface.c +++ b/libdm/ioctl/libdm-iface.c @@ -1250,23 +1250,16 @@ static int _create_and_load_v4(struct dm_task *dmt) /* Use new task struct to create the device */ if (!(task = dm_task_create(DM_DEVICE_CREATE))) { - log_error("Failed to create device-mapper task struct"); _udev_complete(dmt); - return 0; + return_0; } /* Copy across relevant fields */ - if (dmt->dev_name && !dm_task_set_name(task, dmt->dev_name)) { - dm_task_destroy(task); - _udev_complete(dmt); - return 0; - } + if (dmt->dev_name && !dm_task_set_name(task, dmt->dev_name)) + goto_bad; - if (dmt->uuid && !dm_task_set_uuid(task, dmt->uuid)) { - dm_task_destroy(task); - _udev_complete(dmt); - return 0; - } + if (dmt->uuid && !dm_task_set_uuid(task, dmt->uuid)) + goto_bad; task->major = dmt->major; task->minor = dmt->minor; @@ -1278,26 +1271,23 @@ static int _create_and_load_v4(struct dm_task *dmt) task->cookie_set = dmt->cookie_set; task->add_node = dmt->add_node; - r = dm_task_run(task); + if (!dm_task_run(task)) + goto_bad; + dm_task_destroy(task); - if (!r) { - _udev_complete(dmt); - return 0; - } /* Next load the table */ if (!(task = dm_task_create(DM_DEVICE_RELOAD))) { - log_error("Failed to create device-mapper task struct"); + stack; _udev_complete(dmt); - r = 0; goto revert; } /* Copy across relevant fields */ if (dmt->dev_name && !dm_task_set_name(task, dmt->dev_name)) { + stack; dm_task_destroy(task); _udev_complete(dmt); - r = 0; goto revert; } @@ -1311,7 +1301,9 @@ static int _create_and_load_v4(struct dm_task *dmt) task->head = NULL; task->tail = NULL; dm_task_destroy(task); + if (!r) { + stack; _udev_complete(dmt); goto revert; } @@ -1321,13 +1313,11 @@ static int _create_and_load_v4(struct dm_task *dmt) dm_free(dmt->uuid); dmt->uuid = NULL; - r = dm_task_run(dmt); - - if (r) - return r; + if (dm_task_run(dmt)) + return 1; revert: - dmt->type = DM_DEVICE_REMOVE; + dmt->type = DM_DEVICE_REMOVE; dm_free(dmt->uuid); dmt->uuid = NULL; @@ -1347,7 +1337,13 @@ static int _create_and_load_v4(struct dm_task *dmt) if (!dm_task_run(dmt)) log_error("Failed to revert device creation."); - return r; + return 0; + + bad: + dm_task_destroy(task); + _udev_complete(dmt); + + return 0; } uint64_t dm_task_get_existing_table_size(struct dm_task *dmt) @@ -1720,7 +1716,7 @@ int dm_task_run(struct dm_task *dmt) if (!_open_control()) { _udev_complete(dmt); - return 0; + return_0; } if ((suspended_counter = dm_get_suspended_counter()) &&