]> sourceware.org Git - lvm2.git/commitdiff
vg_write: shift check for exported metadata
authorZdenek Kabelac <zkabelac@redhat.com>
Tue, 9 Mar 2021 16:45:42 +0000 (17:45 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Wed, 10 Mar 2021 00:00:18 +0000 (01:00 +0100)
Since we now immediatelly use created buffer for CFT creation,
the result needs to be validate before such use.

lib/format_text/format-text.c

index 3ed6aa54a500f1ba489d263a82e2b7b4d34078c0..64ad4677c23aa571c543020067a4881c0014a145 100644 (file)
@@ -661,6 +661,11 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
                        (void) dm_snprintf(desc, sizeof(desc), "Write[%u] from %s.", vg->write_count, vg->cmd->cmd_line);
 
                new_size = text_vg_export_raw(vg, desc, &write_buf, &write_buf_size);
+               if (!new_size || !write_buf) {
+                       log_error("VG %s metadata writing failed", vg->name);
+                       goto out;
+               }
+
                fidtc->write_buf = write_buf;
                fidtc->write_buf_size = write_buf_size;
                fidtc->new_metadata_size = new_size;
@@ -681,11 +686,6 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
                        goto_out;
        }
 
-       if (!new_size || !write_buf) {
-               log_error("VG %s metadata writing failed", vg->name);
-               goto out;
-       }
-
        log_debug_metadata("VG %s seqno %u metadata write to %s mda_start %llu mda_size %llu mda_last %llu",
                           vg->name, vg->seqno, devname,
                           (unsigned long long)mda_start,
This page took 0.037434 seconds and 5 git commands to generate.