Commit 1acacc0784aab45627b6009e0e9224886279ac0b

Authored by Mike Snitzer
1 parent f3a44fe060

dm thin: fix the error path for the thin device constructor

dm_pool_close_thin_device() must be called if dm_set_target_max_io_len()
fails in thin_ctr().  Otherwise __pool_destroy() will fail because the
pool will still have an open thin device:

 device-mapper: thin metadata: attempt to close pmd when 1 device(s) are still open
 device-mapper: thin: __pool_destroy: dm_pool_metadata_close() failed.

Also, must establish error code if failing thin_ctr() because the pool
is in fail_io mode.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Acked-by: Joe Thornber <ejt@redhat.com>
Cc: stable@vger.kernel.org

Showing 1 changed file with 4 additions and 1 deletions Side-by-side Diff

drivers/md/dm-thin.c
... ... @@ -2895,6 +2895,7 @@
2895 2895  
2896 2896 if (get_pool_mode(tc->pool) == PM_FAIL) {
2897 2897 ti->error = "Couldn't open thin device, Pool is in fail mode";
  2898 + r = -EINVAL;
2898 2899 goto bad_thin_open;
2899 2900 }
2900 2901  
... ... @@ -2906,7 +2907,7 @@
2906 2907  
2907 2908 r = dm_set_target_max_io_len(ti, tc->pool->sectors_per_block);
2908 2909 if (r)
2909   - goto bad_thin_open;
  2910 + goto bad_target_max_io_len;
2910 2911  
2911 2912 ti->num_flush_bios = 1;
2912 2913 ti->flush_supported = true;
... ... @@ -2927,6 +2928,8 @@
2927 2928  
2928 2929 return 0;
2929 2930  
  2931 +bad_target_max_io_len:
  2932 + dm_pool_close_thin_device(tc->td);
2930 2933 bad_thin_open:
2931 2934 __pool_dec(tc->pool);
2932 2935 bad_pool_lookup: