diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c index b2ea2413c..9f0de4cc8 100644 --- a/lib/metadata/raid_manip.c +++ b/lib/metadata/raid_manip.c @@ -1023,6 +1023,7 @@ static int _alloc_image_components(struct logical_volume *lv, struct alloc_handle *ah = NULL; struct dm_list *parallel_areas; struct lv_list *lvl_array; + const char *raid_segtype; if (!(lvl_array = dm_pool_alloc(lv->vg->vgmem, sizeof(*lvl_array) * count * 2))) @@ -1036,9 +1037,8 @@ static int _alloc_image_components(struct logical_volume *lv, else region_size = seg->region_size; - if (seg_is_raid(seg)) - segtype = get_segtype_from_string(lv->vg->cmd, SEG_TYPE_NAME_RAID0_META); - else if (!(segtype = get_segtype_from_string(lv->vg->cmd, SEG_TYPE_NAME_RAID1))) + raid_segtype = seg_is_raid(seg) ? SEG_TYPE_NAME_RAID0_META : SEG_TYPE_NAME_RAID1; + if (!(segtype = get_segtype_from_string(lv->vg->cmd, raid_segtype))) return_0; /* diff --git a/tools/lvconvert.c b/tools/lvconvert.c index 41d32df5b..a37dc25b6 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -2704,7 +2704,8 @@ static int _lvconvert_to_pool(struct cmd_context *cmd, pool_segtype = get_segtype_from_string(cmd, str_seg_type); - if (!pool_segtype->ops->target_present(cmd, NULL, &target_attr)) { + if (!pool_segtype || + !pool_segtype->ops->target_present(cmd, NULL, &target_attr)) { log_error("%s: Required device-mapper target(s) not detected in your kernel.", pool_segtype->name); return 0;