1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Add some log_error msg's and fix potential segfault

Thanks to kabi for spotting these - especially the possibility for
segfault if a loop runs all the way through without finding a match.
This commit is contained in:
Jonathan Earl Brassow 2011-08-11 19:17:10 +00:00
parent 4aebd52c4c
commit b2fa9b43dc
2 changed files with 11 additions and 4 deletions

View File

@ -179,16 +179,20 @@ static int _shift_and_rename_image_components(struct lv_segment *seg)
/* Alter rmeta name */
shift_name = dm_pool_strdup(cmd->mem, seg_metalv(seg, s)->name);
if (!shift_name)
return_0;
if (!shift_name) {
log_error("Memory allocation failed.");
return 0;
}
len = strlen(shift_name) - 1;
shift_name[len] -= missing;
seg_metalv(seg, s)->name = shift_name;
/* Alter rimage name */
shift_name = dm_pool_strdup(cmd->mem, seg_lv(seg, s)->name);
if (!shift_name)
return_0;
if (!shift_name) {
log_error("Memory allocation failed.");
return 0;
}
len = strlen(shift_name) - 1;
shift_name[len] -= missing;
seg_lv(seg, s)->name = shift_name;

View File

@ -2356,6 +2356,9 @@ int dm_tree_node_add_raid_target(struct dm_tree_node *node,
dm_segtypes[i].type, size)))
return_0;
if (!seg)
return_0;
seg->region_size = region_size;
seg->stripe_size = stripe_size;
seg->area_count = 0;