]> sourceware.org Git - lvm2.git/commitdiff
pvmove: check return value of top_level_lv_name()
authorWu Guanghao <wuguanghao3@huawei.com>
Fri, 11 Sep 2020 09:40:09 +0000 (17:40 +0800)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 11 Sep 2020 19:43:08 +0000 (21:43 +0200)
The return value of top_level_lv_name() may be NULL, so we should
check return value of top_level_lv_name before calling
strcmp(lv->name, top_level_lv_name(vg, lv_name)).

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

index cc512b9de2a7dd9f487a16f4f5b3dd52e0d696f8..da635a662d4c2793ac2a17b476d56b6a9b7b388d 100644 (file)
@@ -326,6 +326,7 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
        int lv_skipped = 0;
        int needs_exclusive = *exclusive;
        const struct logical_volume *holder;
+       const char *new_lv_name;
 
        /* FIXME Cope with non-contiguous => splitting existing segments */
        if (!(lv_mirr = lv_create_empty("pvmove%d", NULL,
@@ -363,8 +364,13 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
                if (lv == lv_mirr)
                        continue;
 
-               if (lv_name && strcmp(lv->name, top_level_lv_name(vg, lv_name)))
-                       continue;
+               if (lv_name) {
+                       if (!(new_lv_name = top_level_lv_name(vg, lv_name)))
+                               return_NULL;
+
+                       if (strcmp(lv->name, new_lv_name))
+                               continue;
+               }
 
                if (!lv_is_on_pvs(lv, source_pvl))
                        continue;
This page took 0.040494 seconds and 5 git commands to generate.