summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormajianpeng <majianpeng@gmail.com>2012-05-29 09:21:51 +1000
committerNeilBrown <neilb@suse.de>2012-09-27 16:49:54 +1000
commit0d478e243a90a48fe4da581c7302771f0d66fb3b (patch)
treecc62a2e9f70ba7bc2ff386bcffa3d8608cae6139
parentb7e05d2373313dd8d0cb687479ad58a88f37d29f (diff)
downloadmdadm-0d478e243a90a48fe4da581c7302771f0d66fb3b.tar.gz
mdadm: Fix Segmentation fault.
In function write_init_super1(): If "rv = store_super1(st, di->fd)" return error and the di is the last. Then the di = NULL && rv > 0, so exec: if (rv) fprintf(stderr, Name ": Failed to write metadata to%s\n", di->devname); will be segmentation fault. Signed-off-by: majianpeng <majianpeng@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--super1.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/super1.c b/super1.c
index 4f20cc3..fbc2e8f 100644
--- a/super1.c
+++ b/super1.c
@@ -1096,7 +1096,7 @@ static int write_init_super1(struct supertype *st)
unsigned long long dsize, array_size;
unsigned long long sb_offset, headroom;
- for (di = st->info; di && ! rv ; di = di->next) {
+ for (di = st->info; di; di = di->next) {
if (di->disk.state == 1)
continue;
if (di->fd < 0)
@@ -1242,6 +1242,8 @@ static int write_init_super1(struct supertype *st)
rv = st->ss->write_bitmap(st, di->fd);
close(di->fd);
di->fd = -1;
+ if (rv)
+ goto error_out;
}
error_out:
if (rv)