]> sourceware.org Git - lvm2.git/commitdiff
cov: validate list emptiness
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 29 Jul 2024 14:53:28 +0000 (16:53 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 9 Aug 2024 13:10:18 +0000 (15:10 +0200)
Emit internal error for empty list.

device_mapper/libdm-report.c
lib/metadata/lv_manip.c
libdm/libdm-report.c
tools/lvconvert.c

index d6d4859641e831afb60c71ad1fe2cf31fd34ac27..6301d7e21feb2c3168c7d69f2a6e65d7d43854a1 100644 (file)
@@ -4757,6 +4757,8 @@ static int _output_as_rows(struct dm_report *rh)
        dm_list_iterate_items(fp, &rh->field_props) {
                if (fp->flags & FLD_HIDDEN) {
                        dm_list_iterate_items(row, &rh->rows) {
+                               if (dm_list_empty(&row->fields))
+                                       continue;
                                field = dm_list_item(dm_list_first(&row->fields), struct dm_report_field);
                                dm_list_del(&field->list);
                        }
index 35263b802ff85fc5a1b32bcfcc27cb1b2a90c579..6252c446979e63759dbda5e5fc0076791aafca4c 100644 (file)
@@ -1959,7 +1959,7 @@ static uint32_t _stripes_per_mimage(struct lv_segment *seg)
 
        if (seg_is_mirrored(seg) && seg->area_count && seg_type(seg, 0) == AREA_LV) {
                last_lvseg = dm_list_item(dm_list_last(&seg_lv(seg, 0)->segments), struct lv_segment);
-               if (seg_is_striped(last_lvseg))
+               if (last_lvseg && seg_is_striped(last_lvseg))
                        return last_lvseg->area_count;
        }
 
index 95d5733a215439137c7a85eb0114e23d195b6987..f3a2cfb1174c7b92f0d0ecec18bbf18a6a3db085 100644 (file)
@@ -4755,6 +4755,8 @@ static int _output_as_rows(struct dm_report *rh)
        dm_list_iterate_items(fp, &rh->field_props) {
                if (fp->flags & FLD_HIDDEN) {
                        dm_list_iterate_items(row, &rh->rows) {
+                               if (dm_list_empty(&row->fields))
+                                       continue;
                                field = dm_list_item(dm_list_first(&row->fields), struct dm_report_field);
                                dm_list_del(&field->list);
                        }
index c575f823bf579e1c2ba7ab1b344aa105325e1d2c..220f1a9c557f9ae191dc6fda067657d37fe2b782 100644 (file)
@@ -5792,6 +5792,11 @@ static int _lvconvert_detach_writecache_when_clean(struct cmd_context *cmd,
        int is_lockd;
        int ret = 0;
 
+       if (dm_list_empty(&lr->poll_idls)) {
+               log_error(INTERNAL_ERROR "Cannot detach writecache.");
+               return 0;
+       }
+
        idl = dm_list_item(dm_list_first(&lr->poll_idls), struct convert_poll_id_list);
        id = idl->id;
        is_lockd = lvmcache_vg_is_lockd_type(cmd, id->vg_name, NULL);
This page took 0.054651 seconds and 5 git commands to generate.