Grow_addbitmap(): don't try to close a file descriptor which failed to open

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
Jes Sorensen 2011-11-01 16:09:18 +01:00 committed by NeilBrown
parent 68fe8c6ed0
commit e7344e9007
1 changed files with 6 additions and 5 deletions

11
Grow.c
View File

@ -442,13 +442,14 @@ int Grow_addbitmap(char *devname, int fd, char *file, int chunk, int delay, int
dv = map_dev(disk.major, disk.minor, 1);
if (!dv) continue;
fd2 = dev_open(dv, O_RDONLY);
if (fd2 >= 0 &&
st->ss->load_super(st, fd2, NULL) == 0) {
if (fd2 >= 0) {
if (st->ss->load_super(st, fd2, NULL) == 0) {
close(fd2);
st->ss->uuid_from_super(st, uuid);
break;
}
close(fd2);
st->ss->uuid_from_super(st, uuid);
break;
}
close(fd2);
}
if (d == max_devs) {
fprintf(stderr, Name ": cannot find UUID for array!\n");