Skip to contentSkip to conversation

2018-06-01-stable - lvmanip: uninitialized members in struct pv_list (#10)

PATCH Marian Csontos 1 participant 1 message Dec 19, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=df0797db8cec82df92fb1df2bace184f5a811924
Commit:        df0797db8cec82df92fb1df2bace184f5a811924
Parent:        2d077286b9c6b07fcdd62d834274ae9ab896b195
Author:        Ming-Hung Tsai <[email protected]>
AuthorDate:    Fri Dec 14 01:51:51 2018 -0800
Committer:     Marian Csontos <[email protected]>
CommitterDate: Wed Dec 19 09:18:25 2018 +0100

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

---
 WHATS_NEW               |    1 +
 lib/metadata/lv_manip.c |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)
WHATS_NEW +1 -0
index 02f4ebf..4d1ece4 100644
@@ -1,5 +1,6 @@
 Version 2.02.184 - 
 =====================================
+  Fix missing proper initialization of pv_list struct when adding pv.
 
 Version 2.02.183 - 07th December 2018
 =====================================
lib/metadata/lv_manip.c +1 -1
index e4293cc..d1389e7 100644
@@ -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;
 	}