Commit 0f41fcf7 authored by Helen Koike's avatar Helen Koike Committed by Mike Snitzer

dm ioctl: fix hang in early create error condition

The dm_early_create() function (which deals with "dm-mod.create=" kernel
command line option) calls dm_hash_insert() who gets an extra reference
to the md object.

In case of failure, this reference wasn't being released, causing
dm_destroy() to hang, thus hanging the whole boot process.

Fix this by calling __hash_remove() in the error path.

Fixes: 6bbc923d ("dm: add support to directly boot to a mapped device")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarHelen Koike <helen.koike@collabora.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 05d6909e
...@@ -2069,7 +2069,7 @@ int __init dm_early_create(struct dm_ioctl *dmi, ...@@ -2069,7 +2069,7 @@ int __init dm_early_create(struct dm_ioctl *dmi,
/* alloc table */ /* alloc table */
r = dm_table_create(&t, get_mode(dmi), dmi->target_count, md); r = dm_table_create(&t, get_mode(dmi), dmi->target_count, md);
if (r) if (r)
goto err_destroy_dm; goto err_hash_remove;
/* add targets */ /* add targets */
for (i = 0; i < dmi->target_count; i++) { for (i = 0; i < dmi->target_count; i++) {
...@@ -2116,6 +2116,10 @@ int __init dm_early_create(struct dm_ioctl *dmi, ...@@ -2116,6 +2116,10 @@ int __init dm_early_create(struct dm_ioctl *dmi,
err_destroy_table: err_destroy_table:
dm_table_destroy(t); dm_table_destroy(t);
err_hash_remove:
(void) __hash_remove(__get_name_cell(dmi->name));
/* release reference from __get_name_cell */
dm_put(md);
err_destroy_dm: err_destroy_dm:
dm_put(md); dm_put(md);
dm_destroy(md); dm_destroy(md);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment