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>
This commit is contained in:
parent
572d7091f7
commit
4687f16027
4
super1.c
4
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)
|
||||
|
|
Loading…
Reference in New Issue