Skip to contentSkip to conversation

master - coverity: ensure thin_pool_seg is not NULL

PATCH Zdenek Kabelac 1 participant 1 message Feb 23, 2016

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=63c052b9e2a69b94fea33490130e76aac9a8c735
Commit:        63c052b9e2a69b94fea33490130e76aac9a8c735
Parent:        ddfec5b51a46faab3f64de3e07dc52e0adaf81bc
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Tue Feb 23 21:36:51 2016 +0100
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Tue Feb 23 21:40:17 2016 +0100

coverity: ensure thin_pool_seg is not NULL

thin_pool_seg being NULL would be an internal error.

---
 lib/metadata/lv_manip.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
lib/metadata/lv_manip.c +3 -1
index 64eb6b7..5e4a81f 100644
@@ -1662,8 +1662,10 @@ static int _setup_alloced_segment(struct logical_volume *lv, uint64_t status,
 	lv->size += (uint64_t) extents * lv->vg->extent_size;
 
 	if (lv_is_thin_pool_data(lv)) {
+		if (!(thin_pool_seg = get_only_segment_using_this_lv(lv)))
+			return_0;
+
 		/* Update thin pool segment from the layered LV */
-		thin_pool_seg = get_only_segment_using_this_lv(lv);
 		thin_pool_seg->lv->le_count =
 			thin_pool_seg->len =
 			thin_pool_seg->area_len = lv->le_count;