]> sourceware.org Git - lvm2.git/commitdiff
cov: check for valid raid0 LV segment
authorZdenek Kabelac <zkabelac@redhat.com>
Sat, 4 May 2024 10:38:13 +0000 (12:38 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Tue, 7 May 2024 23:55:21 +0000 (01:55 +0200)
Add internal error to quiet Coverity fear of NULL pointer deref.

lib/metadata/raid_manip.c

index d6103b393419316cc5e7832e2262152b362ff8b4..a4be142acab160d74cbfcb3f1fb66901b859ca09 100644 (file)
@@ -4409,6 +4409,7 @@ static struct lv_segment *_convert_striped_to_raid0(struct logical_volume *lv,
        struct lv_segment *seg, *raid0_seg;
        struct segment_type *segtype;
        struct dm_list data_lvs;
+       struct lv_list *l;
 
        dm_list_iterate_items(seg, &lv->segments)
                area_len += seg->area_len;
@@ -4452,7 +4453,12 @@ static struct lv_segment *_convert_striped_to_raid0(struct logical_volume *lv,
         * areas based on the first data LVs properties derived
         * from the first new raid0 LVs first segment
         */
-       seg = first_seg(dm_list_item(dm_list_first(&data_lvs), struct lv_list)->lv);
+       if (!(l = dm_list_item(dm_list_first(&data_lvs), struct lv_list))) {
+               log_error(INTERNAL_ERROR "Invalid data lvs for raid0 LV %s.",
+                         display_lvname(lv));
+               return NULL;
+       }
+       seg = first_seg(l->lv);
        if (!(raid0_seg = alloc_lv_segment(segtype, lv,
                                           0 /* le */, lv->le_count /* len */,
                                           0, 0,
This page took 0.042643 seconds and 5 git commands to generate.