diff options
author | NeilBrown <neilb@suse.de> | 2011-01-25 07:56:53 +1100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-01-25 07:56:53 +1100 |
commit | 1cc7f4feb9a979fdf7ac4bb06e5632b065d4f4d9 (patch) | |
tree | ab73ac81e3c55388d07589401bdb6c3e6e2b33e7 /super0.c | |
parent | 446d2a5ad48671be2e23676d9ea93af1b8dddf0b (diff) | |
download | mdadm-1cc7f4feb9a979fdf7ac4bb06e5632b065d4f4d9.tar.gz |
Don't close fds in write_init_super
We previously closed all 'fds' associated with an array in
write_init_super .. sometimes, and sometimes at bad times.
This isn't neat and free_super is a better place to close them.
So make sure free_super always closes the fds that the metadata
manager kept hold of, and stop closing them in write_init_super.
Also add a few more calls to free_super to make sure they really do
get closed.
Reported-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'super0.c')
-rw-r--r-- | super0.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -752,8 +752,6 @@ static int write_init_super0(struct supertype *st) fprintf(stderr, Name ": failed to write superblock to %s\n", di->devname); - close(di->fd); - di->fd = -1; } return rv; } @@ -1079,6 +1077,13 @@ static void free_super0(struct supertype *st) { if (st->sb) free(st->sb); + while (st->info) { + struct devinfo *di = st->info; + st->info = di->next; + if (di->fd >= 0) + close(di->fd); + free(di); + } st->sb = NULL; } |