summaryrefslogtreecommitdiffstats
path: root/tools/lvconvert.c
diff options
context:
space:
mode:
authorJonathan Earl Brassow <jbrassow@redhat.com>2012-02-13 18:36:55 +0000
committerJonathan Earl Brassow <jbrassow@redhat.com>2012-02-13 18:36:55 +0000
commit1456c3b298af2e09657a1d46b8e75523786df270 (patch)
tree1f076a42beef3628bce50fb6867cb5fb426a3b4a /tools/lvconvert.c
parenta30832cedd7a844740dc6047597e0cf3b8cbb1e2 (diff)
downloadlvm2-1456c3b298af2e09657a1d46b8e75523786df270.tar.gz
lvm2-1456c3b298af2e09657a1d46b8e75523786df270.tar.xz
lvm2-1456c3b298af2e09657a1d46b8e75523786df270.zip
Fix possible NULL pointer dereferences when updating mirror log.
'_lv_update_log_type' takes a lvconvert_params argument so that it can pass down the user's preference of 'region_size' and allocation_policy. When 'mirror_remove_missing' was introduced (commit ID 95986e42a18ca98c9b1d777346978b7297c85558) it didn't make sense to pass down user preferences - so NULL was given instead. While it may never happen in practice, static analysis reveals that this argument could be dereferenced. So, if the user preferences were not passed in, glean the necessary fields from what is already set in the LV. Reported-by: Zdenek Kabelac <zkabelac@redhat.com> Signed-off-by: Jonathan Brassow <jbrassow@redhat.com> (Not updating WHATSNEW for this simple clean-up.)
Diffstat (limited to 'tools/lvconvert.c')
-rw-r--r--tools/lvconvert.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 86ef01d4..255aea49 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -770,8 +770,10 @@ static int _lv_update_log_type(struct cmd_context *cmd,
struct dm_list *operable_pvs,
int log_count)
{
- uint32_t region_size;
int old_log_count;
+ uint32_t region_size = (lp) ? lp->region_size :
+ first_seg(lv)->region_size;
+ alloc_policy_t alloc = (lp) ? lp->alloc : lv->alloc;
struct logical_volume *original_lv;
struct logical_volume *log_lv;
@@ -793,13 +795,12 @@ static int _lv_update_log_type(struct cmd_context *cmd,
/* Adding redundancy to the log */
if (old_log_count < log_count) {
-
region_size = adjusted_mirror_region_size(lv->vg->extent_size,
lv->le_count,
- lp->region_size);
+ region_size);
if (!add_mirror_log(cmd, original_lv, log_count,
- region_size, operable_pvs, lp->alloc))
+ region_size, operable_pvs, alloc))
return_0;
/*
* FIXME: This simple approach won't work in cluster mirrors,
@@ -812,7 +813,8 @@ static int _lv_update_log_type(struct cmd_context *cmd,
}
/* Reducing redundancy of the log */
- return remove_mirror_images(log_lv, log_count, is_mirror_image_removable, operable_pvs, 1U);
+ return remove_mirror_images(log_lv, log_count,
+ is_mirror_image_removable, operable_pvs, 1U);
}
/*