]> sourceware.org Git - lvm2.git/commitdiff
lvconvert: check if LV has snapshot type
authorWu Guanghao <wuguanghao3@huawei.com>
Fri, 11 Sep 2020 09:42:16 +0000 (17:42 +0800)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 11 Sep 2020 19:48:37 +0000 (21:48 +0200)
Cow may not be a snapshot type, the return value of origin_from_cow(cow) may be NULL

Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
tools/lvconvert.c

index d420eb52f0576e386ce54fb08badfc1d07187ac8..6ab8f6d2c717d473c9a034e6d311209cf6806834 100644 (file)
@@ -1825,6 +1825,11 @@ static int _lvconvert_splitsnapshot(struct cmd_context *cmd, struct logical_volu
        struct volume_group *vg = cow->vg;
        const char *cow_name = display_lvname(cow);
 
+       if (!lv_is_snapshot(cow)) {
+               log_error(INTERNAL_ERROR "Cow volume %s is not a snapshot.", cow_name);
+               return 0;
+       }
+
        if (lv_is_virtual_origin(origin_from_cow(cow))) {
                log_error("Unable to split off snapshot %s with virtual origin.", cow_name);
                return 0;
This page took 0.062388 seconds and 5 git commands to generate.