diff options
author | majianpeng <majianpeng@gmail.com> | 2012-05-29 09:21:51 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-06-05 15:41:14 +1000 |
commit | e9d0fa8c68d531529a3988bbf83ebb2900c11c0d (patch) | |
tree | da7b3aa6971cc9102acca1954aa46155601b069a | |
parent | c94996f693f1ac3acfc3dac86b97a7e5d63e4919 (diff) | |
download | mdadm-data_offset.tar.gz |
mdadm: Fix Segmentation fault.data_offset
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.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -1162,7 +1162,7 @@ static int write_init_super1(struct supertype *st) unsigned long long sb_offset, headroom; long long data_offset; - 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) @@ -1321,6 +1321,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) |