Skip to contentSkip to conversation

master - coverity: validate retval from get_only_segment_using_this_lv

PATCH Zdenek Kabelac 1 participant 1 message Jun 26, 2017

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=275fc2d45bbef5ffaa43a83c1f9572232fdf2268
Commit:        275fc2d45bbef5ffaa43a83c1f9572232fdf2268
Parent:        664e947726ad3e64b59b2e3d43cd4ea01f7e5d5a
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Tue Jun 27 00:24:34 2017 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Tue Jun 27 00:27:36 2017 +0200

coverity: validate retval from get_only_segment_using_this_lv

---
 lib/activate/activate.c |    3 ++-
 lib/display/display.c   |    4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
lib/activate/activate.c +2 -1
index 282dd4f..b3ed513 100644
@@ -781,7 +781,8 @@ int lv_info_with_seg_status(struct cmd_context *cmd,
 	if (lv_is_used_cache_pool(lv)) {
 		/* INFO is not set as cache-pool cannot be active.
 		 * STATUS is collected from cache LV */
-		lv_seg = get_only_segment_using_this_lv(lv);
+		if (!(lv_seg = get_only_segment_using_this_lv(lv)))
+			return_0;
 		(void) _lv_info(cmd, lv_seg->lv, 1, NULL, lv_seg, &status->seg_status, 0, 0);
 		return 1;
 	}
lib/display/display.c +2 -2
index 18e49f9..9a928d9 100644
@@ -517,8 +517,8 @@ int lvdisplay_full(struct cmd_context *cmd,
 		log_print("LV Pool metadata       %s", seg->metadata_lv->name);
 		log_print("LV Pool data           %s", seg_lv(seg, 0)->name);
 	} else if (lv_is_cache_origin(lv)) {
-		log_print("LV origin of Cache LV  %s",
-			  get_only_segment_using_this_lv(lv)->lv->name);
+		if ((seg = get_only_segment_using_this_lv(lv)))
+			log_print("LV origin of Cache LV  %s", seg->lv->name);
 	} else if (lv_is_cache(lv)) {
 		seg = first_seg(lv);
 		if (inkernel && !lv_cache_status(lv, &cache_status))