1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 18:55:19 +03:00

coverity: make sure segtype pointer is valid

This commit is contained in:
Zdenek Kabelac 2017-03-16 00:46:48 +01:00
parent 42b970d4f3
commit e3a51537c5
2 changed files with 5 additions and 4 deletions

View File

@ -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;
/*

View File

@ -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;