diff options
author | Heinz Mauelshagen <heinzm@redhat.com> | 2016-06-24 15:49:26 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2016-07-18 15:37:28 -0400 |
commit | b1956dc4fa5c055e2229b848de418f1528ae7990 (patch) | |
tree | 49e0b31333ae124e735cdeef6a3bc1d2c5d7c08c /drivers/md/dm-raid.c | |
parent | 65359ee6b106cfb74b50bd0f63714955371ef780 (diff) |
dm raid: fix ctr memory leaks on error paths
Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm-raid.c')
-rw-r--r-- | drivers/md/dm-raid.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c index 109d698d1704..2fb5a9bff1bb 100644 --- a/drivers/md/dm-raid.c +++ b/drivers/md/dm-raid.c | |||
@@ -2738,7 +2738,7 @@ static int raid_ctr(struct dm_target *ti, unsigned argc, char **argv) | |||
2738 | */ | 2738 | */ |
2739 | r = rs_set_dev_and_array_sectors(rs, false); | 2739 | r = rs_set_dev_and_array_sectors(rs, false); |
2740 | if (r) | 2740 | if (r) |
2741 | return r; | 2741 | goto bad; |
2742 | 2742 | ||
2743 | calculated_dev_sectors = rs->dev[0].rdev.sectors; | 2743 | calculated_dev_sectors = rs->dev[0].rdev.sectors; |
2744 | 2744 | ||
@@ -2769,20 +2769,23 @@ static int raid_ctr(struct dm_target *ti, unsigned argc, char **argv) | |||
2769 | if (rs_is_raid6(rs) && | 2769 | if (rs_is_raid6(rs) && |
2770 | test_bit(__CTR_FLAG_NOSYNC, &rs->ctr_flags)) { | 2770 | test_bit(__CTR_FLAG_NOSYNC, &rs->ctr_flags)) { |
2771 | ti->error = "'nosync' not allowed for new raid6 set"; | 2771 | ti->error = "'nosync' not allowed for new raid6 set"; |
2772 | return -EINVAL; | 2772 | r = -EINVAL; |
2773 | goto bad; | ||
2773 | } | 2774 | } |
2774 | rs_setup_recovery(rs, 0); | 2775 | rs_setup_recovery(rs, 0); |
2775 | } else if (rs_is_recovering(rs) || rs_is_reshaping(rs)) { | 2776 | } else if (rs_is_recovering(rs) || rs_is_reshaping(rs)) { |
2776 | /* Have to reject size change request during recovery/reshape */ | 2777 | /* Have to reject size change request during recovery/reshape */ |
2777 | if (calculated_dev_sectors != rs->dev[0].rdev.sectors) { | 2778 | if (calculated_dev_sectors != rs->dev[0].rdev.sectors) { |
2778 | ti->error = "Can't resize a recovering/reshaping raid set"; | 2779 | ti->error = "Can't resize a recovering/reshaping raid set"; |
2779 | return -EPERM; | 2780 | r = -EPERM; |
2781 | goto bad; | ||
2780 | } | 2782 | } |
2781 | /* skip setup rs */ | 2783 | /* skip setup rs */ |
2782 | } else if (rs_takeover_requested(rs)) { | 2784 | } else if (rs_takeover_requested(rs)) { |
2783 | if (rs_is_reshaping(rs)) { | 2785 | if (rs_is_reshaping(rs)) { |
2784 | ti->error = "Can't takeover a reshaping raid set"; | 2786 | ti->error = "Can't takeover a reshaping raid set"; |
2785 | return -EPERM; | 2787 | r = -EPERM; |
2788 | goto bad; | ||
2786 | } | 2789 | } |
2787 | 2790 | ||
2788 | /* | 2791 | /* |
@@ -2792,11 +2795,11 @@ static int raid_ctr(struct dm_target *ti, unsigned argc, char **argv) | |||
2792 | */ | 2795 | */ |
2793 | r = rs_check_takeover(rs); | 2796 | r = rs_check_takeover(rs); |
2794 | if (r) | 2797 | if (r) |
2795 | return r; | 2798 | goto bad; |
2796 | 2799 | ||
2797 | r = rs_setup_takeover(rs); | 2800 | r = rs_setup_takeover(rs); |
2798 | if (r) | 2801 | if (r) |
2799 | return r; | 2802 | goto bad; |
2800 | 2803 | ||
2801 | set_bit(RT_FLAG_UPDATE_SBS, &rs->runtime_flags); | 2804 | set_bit(RT_FLAG_UPDATE_SBS, &rs->runtime_flags); |
2802 | set_bit(RT_FLAG_KEEP_RS_FROZEN, &rs->runtime_flags); | 2805 | set_bit(RT_FLAG_KEEP_RS_FROZEN, &rs->runtime_flags); |
@@ -2804,7 +2807,8 @@ static int raid_ctr(struct dm_target *ti, unsigned argc, char **argv) | |||
2804 | } else if (rs_reshape_requested(rs)) { | 2807 | } else if (rs_reshape_requested(rs)) { |
2805 | if (rs_is_reshaping(rs)) { | 2808 | if (rs_is_reshaping(rs)) { |
2806 | ti->error = "raid set already reshaping!"; | 2809 | ti->error = "raid set already reshaping!"; |
2807 | return -EPERM; | 2810 | r = -EPERM; |
2811 | goto bad; | ||
2808 | } | 2812 | } |
2809 | 2813 | ||
2810 | if (rs_is_raid10(rs)) { | 2814 | if (rs_is_raid10(rs)) { |
@@ -2820,7 +2824,8 @@ static int raid_ctr(struct dm_target *ti, unsigned argc, char **argv) | |||
2820 | */ | 2824 | */ |
2821 | if (rs->raid_disks % rs->raid10_copies) { | 2825 | if (rs->raid_disks % rs->raid10_copies) { |
2822 | ti->error = "Can't reshape raid10 mirror groups"; | 2826 | ti->error = "Can't reshape raid10 mirror groups"; |
2823 | return -EINVAL; | 2827 | r = -EINVAL; |
2828 | goto bad; | ||
2824 | } | 2829 | } |
2825 | 2830 | ||
2826 | /* Userpace reordered disks to add/remove mirrors -> adjust raid_disk indexes */ | 2831 | /* Userpace reordered disks to add/remove mirrors -> adjust raid_disk indexes */ |
@@ -2865,7 +2870,7 @@ static int raid_ctr(struct dm_target *ti, unsigned argc, char **argv) | |||
2865 | /* If constructor requested it, change data and new_data offsets */ | 2870 | /* If constructor requested it, change data and new_data offsets */ |
2866 | r = rs_adjust_data_offsets(rs); | 2871 | r = rs_adjust_data_offsets(rs); |
2867 | if (r) | 2872 | if (r) |
2868 | return r; | 2873 | goto bad; |
2869 | 2874 | ||
2870 | /* Start raid set read-only and assumed clean to change in raid_resume() */ | 2875 | /* Start raid set read-only and assumed clean to change in raid_resume() */ |
2871 | rs->md.ro = 1; | 2876 | rs->md.ro = 1; |
@@ -2899,7 +2904,7 @@ static int raid_ctr(struct dm_target *ti, unsigned argc, char **argv) | |||
2899 | if (test_bit(RT_FLAG_RESHAPE_RS, &rs->runtime_flags)) { | 2904 | if (test_bit(RT_FLAG_RESHAPE_RS, &rs->runtime_flags)) { |
2900 | r = rs_check_reshape(rs); | 2905 | r = rs_check_reshape(rs); |
2901 | if (r) | 2906 | if (r) |
2902 | return r; | 2907 | goto bad_check_reshape; |
2903 | 2908 | ||
2904 | /* Restore new, ctr requested layout to perform check */ | 2909 | /* Restore new, ctr requested layout to perform check */ |
2905 | rs_config_restore(rs, &rs_layout); | 2910 | rs_config_restore(rs, &rs_layout); |