Skip to content

Commit

Permalink
dm ioctl: fix hang in early create error condition
Browse files Browse the repository at this point in the history
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: 6bbc923 ("dm: add support to directly boot to a mapped device")
Cc: stable@vger.kernel.org
Signed-off-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
  • Loading branch information
Helen Koike authored and Mike Snitzer committed May 16, 2019
1 parent 05d6909 commit 0f41fcf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/md/dm-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2069,7 +2069,7 @@ int __init dm_early_create(struct dm_ioctl *dmi,
/* alloc table */
r = dm_table_create(&t, get_mode(dmi), dmi->target_count, md);
if (r)
goto err_destroy_dm;
goto err_hash_remove;

/* add targets */
for (i = 0; i < dmi->target_count; i++) {
Expand Down Expand Up @@ -2116,6 +2116,10 @@ int __init dm_early_create(struct dm_ioctl *dmi,

err_destroy_table:
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:
dm_put(md);
dm_destroy(md);
Expand Down

0 comments on commit 0f41fcf

Please sign in to comment.