From c04042cf7b7d4de3d892c6078787af8e29fd3c8a Mon Sep 17 00:00:00 2001 From: root Date: Wed, 13 Mar 2019 14:23:39 +0800 Subject: [PATCH 10/17] lvmanip: uninitialized members in struct pv_list (#10) Scenario: Given an existed LV `lvol0`, I want to create another LV on the PVs used by `lvol0`. I use `build_parallel_areas_from_lv()` to obtain the `pv_list` of each segments. However, the returned `pv_list` is not properly initialized, which causes segfault in subsequent operations. (cherry picked from commit 859feb81e5b61ac2109b1d7850844ccf1ce3e5bf) (cherry picked from commit 219ba4f54a462c175f5e9acaa0558afac94d5ff7) Conflicts: WHATS_NEW --- lib/metadata/lv_manip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index e4293cc..d1389e7 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -5860,7 +5860,7 @@ static int _add_pvs(struct cmd_context *cmd, struct pv_segment *peg, if (find_pv_in_pv_list(&spvs->pvs, peg->pv)) return 1; - if (!(pvl = dm_pool_alloc(cmd->mem, sizeof(*pvl)))) { + if (!(pvl = dm_pool_zalloc(cmd->mem, sizeof(*pvl)))) { log_error("pv_list allocation failed"); return 0; } -- 2.19.1