diff options
author | Helen Koike <helen.koike@collabora.com> | 2019-05-15 12:50:54 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2019-05-16 09:52:06 -0400 |
commit | 0f41fcf78849c902ddca564f99a8e23ccfc80333 (patch) | |
tree | e56d03d13d08cb5b901e057dc008099e77e2809c | |
parent | 05d6909ea9d62bb357846177a84842e09fc15914 (diff) |
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: 6bbc923dfcf57d ("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>
-rw-r--r-- | drivers/md/dm-ioctl.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index c740153b4e52..1e03bc89e20f 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c | |||
@@ -2069,7 +2069,7 @@ int __init dm_early_create(struct dm_ioctl *dmi, | |||
2069 | /* alloc table */ | 2069 | /* alloc table */ |
2070 | r = dm_table_create(&t, get_mode(dmi), dmi->target_count, md); | 2070 | r = dm_table_create(&t, get_mode(dmi), dmi->target_count, md); |
2071 | if (r) | 2071 | if (r) |
2072 | goto err_destroy_dm; | 2072 | goto err_hash_remove; |
2073 | 2073 | ||
2074 | /* add targets */ | 2074 | /* add targets */ |
2075 | for (i = 0; i < dmi->target_count; i++) { | 2075 | for (i = 0; i < dmi->target_count; i++) { |
@@ -2116,6 +2116,10 @@ int __init dm_early_create(struct dm_ioctl *dmi, | |||
2116 | 2116 | ||
2117 | err_destroy_table: | 2117 | err_destroy_table: |
2118 | dm_table_destroy(t); | 2118 | dm_table_destroy(t); |
2119 | err_hash_remove: | ||
2120 | (void) __hash_remove(__get_name_cell(dmi->name)); | ||
2121 | /* release reference from __get_name_cell */ | ||
2122 | dm_put(md); | ||
2119 | err_destroy_dm: | 2123 | err_destroy_dm: |
2120 | dm_put(md); | 2124 | dm_put(md); |
2121 | dm_destroy(md); | 2125 | dm_destroy(md); |