close_aa(): Verify file descriptors are valid before trying to close them

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-03 08:08:23 +11:00 committed by NeilBrown
parent 3e1d79b2d6
commit c20478757d
1 changed files with 10 additions and 5 deletions

View File

@ -117,11 +117,16 @@ static void close_aa(struct active_array *aa)
close(d->state_fd);
}
close(aa->action_fd);
close(aa->info.state_fd);
close(aa->resync_start_fd);
close(aa->metadata_fd);
close(aa->sync_completed_fd);
if (aa->action_fd >= 0)
close(aa->action_fd);
if (aa->info.state_fd >= 0)
close(aa->info.state_fd);
if (aa->resync_start_fd >= 0)
close(aa->resync_start_fd);
if (aa->metadata_fd >= 0)
close(aa->metadata_fd);
if (aa->sync_completed_fd >= 0)
close(aa->sync_completed_fd);
}
static void free_aa(struct active_array *aa)