From c20478757de9b2746860365a3d644c441fb87f97 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Thu, 3 Nov 2011 08:08:23 +1100 Subject: [PATCH] close_aa(): Verify file descriptors are valid before trying to close them Signed-off-by: Jes Sorensen Signed-off-by: NeilBrown --- managemon.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/managemon.c b/managemon.c index fceaeb9c..cde0d8be 100644 --- a/managemon.c +++ b/managemon.c @@ -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) -- 2.47.2