]> sourceware.org Git - lvm2.git/commitdiff
Fix unhandled condition in _move_lv_segments
authorJonathan Earl Brassow <jbrassow@redhat.com>
Fri, 25 Mar 2011 22:02:27 +0000 (22:02 +0000)
committerJonathan Earl Brassow <jbrassow@redhat.com>
Fri, 25 Mar 2011 22:02:27 +0000 (22:02 +0000)
If _move_lv_segments is passed a 'lv_from' that does not yet
have any segments, it will screw things up because the code
that does the segment copy assumes there is at least one
segment.  See copy code here:
        lv_to->segments = lv_from->segments;
        lv_to->segments.n->p = &lv_to->segments;
        lv_to->segments.p->n = &lv_to->segments;

If 'segments' is an empty list, the first statement copies over
the values, but the next two reset those values to point to the
other LV's list structure.  'lv_to' now appears to have one
segment, but it is really an ill-set pointer.

lib/metadata/lv_manip.c

index ee3a289a8eca9548d7f486b582a44c5d0c6eb02b..015c48118ce310307e92e711814fedcf1a861f2f 100644 (file)
@@ -2950,7 +2950,8 @@ static int _move_lv_segments(struct logical_volume *lv_to,
                }
        }
 
-       lv_to->segments = lv_from->segments;
+       if (!dm_list_empty(&lv_from->segments))
+               lv_to->segments = lv_from->segments;
        lv_to->segments.n->p = &lv_to->segments;
        lv_to->segments.p->n = &lv_to->segments;
 
This page took 0.032828 seconds and 5 git commands to generate.